-
Notifications
You must be signed in to change notification settings - Fork 246
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
Logs do not flush before Java exit #3009
Comments
@all-contributors add @ZachBien for bug |
I've put up a pull request to add @ZachBien! 🎉 |
Okay I was able to reproduce this on JDK8 (Amazon Corretto 8), but not with Amazon Corretto 17. It does look like this might be caused by how the JVM handles the subprocess... |
In some cases, messages sent by JavaScript using `console.log` and similar may not be completely flushed by the time the Java thread that forwards that data is closed. This is because the thread might not have been given a chance to run when `this.stop` is set to true, which makes it exit immediately. This change adds a new step that triggers once `this.stop` becomes `true` that will flush the `inputStream` until EOF in a blocking way. When this happens, the child process has already been requested to exit, and so EOF should be reached relatively quickly. Fixes #3009
In some cases, messages sent by JavaScript using `console.log` and similar may not be completely flushed by the time the Java thread that forwards that data is closed. This is because the thread might not have been given a chance to run when `this.stop` is set to true, which makes it exit immediately. This change adds a new step that triggers once `this.stop` becomes `true` that will flush the `inputStream` until EOF in a blocking way. When this happens, the child process has already been requested to exit, and so EOF should be reached relatively quickly. Fixes #3009 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
|
🐛 Bug Report
Affected Languages
TypeScript
orJavascript
Python
Java
C#
,F#
, ...)Go
General Information
What is the problem?
console.log("Log lines")
are not guaranteed to be written when executed in the Java export. It appears that the logs are not flushed in JavaScript before the Java program exits. Sleeping/Debugging at the end of the the Java program allows the JavaScript logs to be written.Jsii TS code:
Java code:
I will only see the output from the TS log (
Mocked impl...
) if I debug the Java program at the last line.The text was updated successfully, but these errors were encountered: