Moonshine-IDE
Moonshine-IDE copied to clipboard
Abrupt throwing of Error #3218 Error while writing data to NativeProcess.standardInput.
While using Moonshine, time to time I noticed following errors generated to its console. However, it doesn't tell enough information from where the error fired - neither I found any proper steps to reproduce this. Some this even fired when Moonshine starts.
I'd like to keep this documented for future possible investigation.
: Moonshine IDE 2.0.0
: Source code is under Apache License, Version 2.0
: https://github.com/prominic/Moonshine-IDE
: Uses as3abc (LGPL), as3swf (MIT), fzip (ZLIB), asblocks (Apache License 2.0), NativeApplicationUpdater (LGPL)
: Running on Adobe AIR 32.0.0.89
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
Looking into the ActionScript error dictionary, Error#3218 means:
3218 | Error while writing data to NativeProcess.standardInput.
Since this error fires abruptly, this would became difficult to judge where or which function cause this.
I able to reproduce this error on Windows by following these steps most of the times now:
- Make sure Moonshine has its default SDK and Java path set
- Open a project to Moonshine
- Open a file from the project to editor
- Restart Moonshine
- When Moonshine fully started by opening previous project and its files to the editor and language-server started against the project, try to hover the source in opened editor - sometime Error#3218 throws here
- If above test did not thrown any error and worked appropriately, close the project from sidebar
- Open
Moonshine -> Settings -> Default SDK
, clear the Java path and save - Open the previous project from RECENT section, make sure one file also opened to the editor from the project
- Language server shouldn't work at this moment to the project
- Go to
Help -> Getting Started
- If OpenJDK already downloaded to Moonshine SDK Installer default location, or system environment has a valid JAVA_HOME path, opening Getting Started will reset the Moonshine Java path with proper value
- If 11 pass successfully you shall see language-server starts (in bottom statusbar) to the already opened project
- As soon language-server start progressbar disappears (from bottom statusbar), activate the editor which had opened with the file from the project
- Try to move mouse in the editor - console throws Error#3218
I have a growing feeling this is somehow related to language-server process. To test my suspicion, if I comment-out MOUSE_MOVE and ROLL_OUT events from LanguageServerTextEditor file I do not see the above error fires anymore. @joshtynjala do you think about any reason that could cause throwing the error after MOUSE_MOVE and ROLL_OUT events here?
Moonshine communicates with the language server NativeProcess over standard input/output. This error could be thrown if the process has exited, but some part of Moonshine mistakenly thinks that it's still running.
I think that I can see a situation where the NativeProcess could exit, but the event listeners in the LanguageClient class would still be active. Unfortunately, I haven't been able to reproduce the issue yet.
I can reproduce by force closing the Java process from the Windows Task Manager.
My latest changes should prevent this error and clean things up better. Please let me know if you can still reproduce or not.
Unfortunately, this didn't seem fixed for me with current Moonshine build downloaded from Bamboo. I still receiving this:
: Error #3218
:
: Click here to Report a Bug
: Error #3218
:
: Click here to Report a Bug
: Error #3218
No solution yet, but just an update to say that I can still reproduce this issue too.
I have determined that it happens when the language server takes a long time to respond. The NativeProcess.standardInput
buffer is filled to capacity as too many new requests are queued while it waits for the previous response.
I found that breaking up messages sent to the language server into multiple parts, if the length is larger than 512 characters, seems to stop Error 3218 from being thrown in some circumstances.
In particular, I found that this error was thrown when using Ctrl+Click to open a very large file. Passing the file as a single string resulted in a very large message that could cause this error, but passing it in several smaller strings seems to allow the buffer to clear.
This may not stop the error everywhere that it happens, but I think that it should help quite a bit.
Hi @joshtynjala . This error occurs to me in following scenario.
- Launch Moonshine and some project (in my case it was Royale one)
- Open some file
- Switch off Moonshine and launch again
- Once previously opened file launch quickly roll over on any code to see tooltips
Results in debugger version (Moonshine source code launched from IDE):
[trace] Error: Failed to update language server capability. Unknown method: workspace/didChangeWatchedFiles
[trace] Error #2044: Unhandled IOErrorEvent:. text=Error #3218: Error while writing data to NativeProcess.standardInput.
[trace] Error #2044: Unhandled IOErrorEvent:. text=Error #3218: Error while writing data to NativeProcess.standardInput.
Thanks, Piotr.
This one can be safely ignored. It's a non-critical part of the language server protocol that I haven't implemented yet:
Error: Failed to update language server capability. Unknown method: workspace/didChangeWatchedFiles
However, I will investigate this one:
[trace] Error #2044: Unhandled IOErrorEvent:. text=Error #3218: Error while writing data to NativeProcess.standardInput.
However, I will investigate this one:
[trace] Error #2044: Unhandled IOErrorEvent:. text=Error #3218: Error while writing data to NativeProcess.standardInput.
@joshtynjala could you please take a look into that, cause It's starting to be really annoying.
@piotrzarzycki21 Looking into it...
@piotrzarzycki21 Let me know if that change helps, or if it causes any unexpected issues. Thanks!
@piotrzarzycki21 Let me know if that change helps, or if it causes any unexpected issues. Thanks!
Josh it looks like it's working. Thank you finally one annoying distraction less. :)
I started experiencing this issue using the latest development build. It seems intermittent. It happens for me:
- sometimes when I click on a
.as
class in ProjectView to open it in the Editor - sometimes when I edit
.as
files - almost always when I rebuild MoonshineDESKTOPevolved
almost always when I rebuild MoonshineDESKTOPevolved
I wonder if I need to debounce the file system watcher events, similar to what I did with hover/definition. If this error happens during a build, it's probably caused by copying source path assets to the output folder.
Here's a video recorded on the latest Moonshine Development. It shows how annoying this error can be.
Screencast from 09-21-2022 01:12:08 PM.webm
For me, it makes debugging other issues considerably harder. For @piotrzarzycki21 it makes impossible working on larger project for his clients.
I can confirm I can reproduce the error following @Aszusz 's steps on the Windows build.
Error #2044: Unhandled IOErrorEvent:. text=Error #3218: Error while writing data to NativeProcess.standardInput.
I'll look into it quickly while I have the necessary debug tools open.
I just realized that when I added the code to use a socket instead of stdio in AS3/MXML projects (commit 0cbd1968b408f2f6e870082b062552827a3be377), I didn't actually set the _useSocket
flag to true. So my attempted fix for this error hasn't actually been tested yet. I'll try to get that committed today, if I can work through a minor issue.
Thanks @joshtynjala, the fix works great for me and @piotrzarzycki21. I'm closing the issue.
the fix works great for me. I'm closing the issue.
I switched to using socket instead of stdio for the AS3/MXML language server, and it's great to hear that this helped. However, the issue isn't technically fixed. It's just a workaround. Especially since not all language servers support sockets.
I mentioned this in a previous comment:
I wonder if I need to debounce the file system watcher events, similar to what I did with hover/definition. If this error happens during a build, it's probably caused by copying source path assets to the output folder.
I still plan to investigate this part. If I can reproduce and get it fixed locally, I will probably switch back to stdio from socket to see if you guys still get the error or not.