Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positron breaks after sending multiple emails with SMTP #5686

Open
Upipa opened this issue Dec 10, 2024 · 7 comments
Open

Positron breaks after sending multiple emails with SMTP #5686

Upipa opened this issue Dec 10, 2024 · 7 comments
Labels
info needed Waiting on information lang: r os-windows Windows issue

Comments

@Upipa
Copy link

Upipa commented Dec 10, 2024

System details:

Positron and OS details:

Positron Version: 2024.12.0 (system setup) build 96
Code - OSS Version: 1.93.0
Commit: c5ce275
Date: 2024-11-28T02:50:45.229Z
Electron: 30.4.0
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.26100

Interpreter details:

R 4.4.2

Describe the issue:

I was using the package blastula to render parametrized emails and send them with SMTP. The script use a purrr::pwalk call to a function defined as a formula similar to the following

smtp_send(
  blastula::render_email("parametrized-mail.Rmd", render_options = list(params = list(parameter = .))),
  from = "[email protected]",
  to = "[email protected]", # sending to myself for testing purposes
  subject = .,
  credentials = creds_key("creds-id")
)

on a tibble of just 5 rows. After sending the first 2 emails succesfully R crushes like this

Image

The restarting button doesn't work. After closing and reopening Positron, it can't find any interpreter

Image

Following the suggestion, on the dropdown menù on the top right it's visible an R interpreter but nothing happens when trying to click it. The only way i found to unstuck positron from this problem is by reinstalling it.

Steps to reproduce the issue:

It's difficult to define a step by step guide since the setting is very user-specific. I simply tried to render and send with SMTP some emails rendered with {blastula}. I'll leave an example code of what i have done

R script

library(blastula)
library(tidyverse)


tibble_containing_parameters |>
slice_sample(n = 5) |> 
pwalk(~smtp_send(
  render_email("mail-to-render.Rmd", render_options = list(params = list(parameter = .))),
  from = "[email protected]",
  to = "[email protected]", # sending to myself for testing purposes
  subject = .,
  credentials = creds_key("creds-id")
))

Rmd file


title: "Title"
output: blastula::blastula_email
params:
parameter: NA
echo: false
warning: false
message: false

#| label: setup

library(tidyverse)
library(readxl)
library(janitor)
library(gt)
read_excel("data.xlsx") |>
  clean_names() |>
  filter(
    parameter == params$parameter
  ) |> 
    gt()

VERY IMPORTANT

Despite i can't give exact code to reproduce my environment, i think it might not be directly related to the task itself of sending emails with R. The problem I had is nearly identical to one I have reported a week or two ago right here #5563. The setting is completely different but the end result is completely identical. Last time i failed to give detailed log of what happened because the bug didn't occur anymore for some reason. This time i wanted to open a more complete issue on the bug in the hope to actually find a way to fix this bug.

Expected or desired behavior:

I would expect that R doesn't crush, because this would mean that i can't to this kind of "massive" email sending with Positron, a thing that i've already done easely with Rstudio. But beside that ,the very painful part is that i'm forced to reinstall Positron in order to be able to using it again.

Were there any error messages in the UI, Output panel, or Developer Tools console?

R logs

Console

2024-12-10 17:10:27.079 [debug] State: idle => busy (execute_request)
2024-12-10 17:10:44.106 [debug] State: busy => exited (child process exited)
2024-12-10 17:10:44.106 [info] Kernel exited with code 0; cleaning up.
2024-12-10 17:10:44.109 [info] Websocket closed with kernel in status exited: {}

Positron R Language Server

[Error - 5:10:43 PM] Client Positron R Language Server (4.4.2): connection to server is erroring.
read ECONNRESET
Shutting down server.
[Error - 5:10:43 PM] Client Positron R Language Server (4.4.2): connection to server is erroring.
read ECONNRESET
Shutting down server.
[Error - 5:10:43 PM] Client Positron R Language Server (4.4.2): connection to server is erroring.
Cannot call write after a stream was destroyed
Shutting down server.
[Error - 5:10:43 PM] Stopping server failed
Message: Cannot call write after a stream was destroyed
Code: -32099
[Error - 5:10:43 PM] Stopping server failed
Message: Cannot call write after a stream was destroyed
Code: -32099
[Error - 5:10:43 PM] Stopping server failed
Message: Cannot call write after a stream was destroyed
Code: -32099
[Error - 5:10:43 PM] Stopping server failed
Message: Cannot call write after a stream was destroyed
Code: -32099

Developer Tools

ERR [Extension Host] Sending request failed.
workbench.desktop.main.js:62543 [Extension Host] Sending request failed. (at console. (c:\Program Files\Positron\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:64217:26))
log @ workbench.desktop.main.js:62543
workbench.desktop.main.js:130821 DEBUG [Runtime startup] Saving workspace sessions (0)
workbench.desktop.main.js:62543 [Extension Host] rejected promise not handled within 1 second: Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed (at console. (c:\Program Files\Positron\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:64217:26))
log @ workbench.desktop.main.js:62543
workbench.desktop.main.js:62543 [Extension Host] stack trace: Error: Cannot call write after a stream was destroyed
at _write (node:internal/streams/writable:483:11)
at Writable.write (node:internal/streams/writable:502:10)
at c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:125041
at new Promise ()
at a.write (c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:124959)
at y.doWrite (c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:112577)
at c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:112472 (at console. (c:\Program Files\Positron\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:64217:26))
log @ workbench.desktop.main.js:62543
workbench.desktop.main.js:507375 [positron.positron-r]Cannot call write after a stream was destroyed
$onExtensionRuntimeError @ workbench.desktop.main.js:507375
workbench.desktop.main.js:507376 Error: Cannot call write after a stream was destroyed
at _write (node:internal/streams/writable:483:11)
at Writable.write (node:internal/streams/writable:502:10)
at c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:125041
at new Promise ()
at a.write (c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:124959)
at y.doWrite (c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:112577)
at c:\Program Files\Positron\resources\app\extensions\positron-r\dist\extension.js:1:112472

@jennybc
Copy link
Member

jennybc commented Dec 10, 2024

Just in terms of your feeling that you have to reinstall Positron to get unstuck, if you have this problem again, here is a less draconian thing to try (just resetting Positron's state):

https://positron.posit.co/troubleshooting.html#resetting-positron

rm -rf "~/Library/Application Support/Positron"
rm -rf ~/.positron

The first removal resets Positron's state and that is what might help you recover, until we get a better handle on what's wrong. The second removal is about extensions and may not be necessary in your case.

Now, I realize you're on Windows and those hints are for macOS. The relevant folders are below %APPDATA%\Roaming\Positron in your case, I think.

@jennybc
Copy link
Member

jennybc commented Dec 10, 2024

OS: Windows_NT x64 10.0.26100

Are you running an experimental version of Windows? Is your hardware ARM64? Nevermind. My usual method of learning more about a Windows version (asking an LLM) obviously doesn't work very well for a very current version, which is what this seems to be. But if there is anything unusual about your setup, speak up.

@jennybc jennybc added os-windows Windows issue lang: r info needed Waiting on information labels Dec 10, 2024
@Upipa
Copy link
Author

Upipa commented Dec 11, 2024

No, there's nothing unusual in my OS, is a simple install of Windows 11 Pro

@jennybc
Copy link
Member

jennybc commented Dec 11, 2024

I agree with your hunch that it may not have anything to do with the specific R activity you're doing. So, going back to (#5563 (comment)), we will need to see some of your logs.

https://positron.posit.co/troubleshooting.html#python-and-r-logs

The ones that start with "R 4.4.2 ..." (or whatever specific version you're using) are likely to be the most informative.

@Upipa
Copy link
Author

Upipa commented Dec 12, 2024

I've put all the logs above, it's missing only the R 4.2.2 kernel. I integrate with the kernel logs now:

[R] 2024-12-12T08:51:27.118820Z ERROR Error receiving internal Help message: RecvError
[R] at crates\ark\src\help\r_help.rs:127
[R]
[R] 2024-12-12T08:51:27.173859Z ERROR Error receiving Positron event; closing event listener: RecvError
[R] at crates\ark\src\ui\ui.rs:70

@jennybc
Copy link
Member

jennybc commented Dec 12, 2024

In the kernel log, I see an entry related to Help. Do you recall making any explicit move to access Help?

@jennybc
Copy link
Member

jennybc commented Dec 12, 2024

Can you also tell me a bit more about your system? Specifically, which of these do you use to install Positron?

  • Setup.exe for Windows 10, 11 x64 (system level install)
  • UserSetup.exe for Windows 10, 11 x64 (user level install)

Is there anything interesting (as in constrained) about your permissions on this system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed Waiting on information lang: r os-windows Windows issue
Projects
None yet
Development

No branches or pull requests

2 participants