-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Propagate exception to wasm-js and js in propagateExceptionFinalResort
#4472
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks!
throw IllegalStateException("My ISE") | ||
} | ||
job.join() | ||
delay(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Please add a comment to the code.
} | ||
|
||
@Test | ||
fun testThrows() = runTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd expect a more descriptive name, like testHandlingUncaughtExceptionsInNodeJs
. Maybe even a documentation comment explaining what exactly we are checking here. Given how much JS code there is in this file, it's not trivial to figure out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like test name is too short to include a very specific descriptive name, so I've only added a comment. Do you want me to rename the test name anyway into the next best thing? (I assume with the goal of having a better name should this test fail.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having a rough idea of what failed when you see the list of failed tests after introducing a change is the point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just that all the info is in the class name + path (for platform), and naming this accurately would be duplicating those. Had we had a dozen tests, we wouldn't be naming them so verbosely. I've done it anyways for now.
kotlinx-coroutines-core/jsAndWasmJsShared/src/internal/CoroutineExceptionHandlerImpl.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/jsAndWasmJsShared/src/internal/CoroutineExceptionHandlerImpl.kt
Show resolved
Hide resolved
kotlinx-coroutines-core/wasmJs/src/internal/CoroutineExceptionHandlerImpl.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/wasmJs/test/PropagateExceptionFinalResortTest.kt
Outdated
Show resolved
Hide resolved
kotlinx-coroutines-core/wasmJs/test/PropagateExceptionFinalResortTest.kt
Outdated
Show resolved
Hide resolved
Idea's internal formatter (CMD+Option+L) wants to format all
Instead of the simpler this, which is also the way it is written in docs.
Should we override the formatter, locally or globally, for this particular function? |
What the IDE does is not the style used in our style guide: https://kotlinlang.org/docs/coding-conventions.html#strings Worth filing a bug, but I'm not sure who is wrong: the IDE, the style guide, or both. The important thing, though, is for a project to have a consistent style, the specifics don't matter that much. In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, thank you! I only have some minor remarks, but otherwise, this is good to go.
} | ||
|
||
@Test | ||
fun testThrows() = runTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, having a rough idea of what failed when you see the list of failed tests after introducing a change is the point.
throw IllegalStateException("My ISE") | ||
} | ||
job.join() | ||
delay(1) // Let the exception be re-thrown and handled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: an extra space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, double space before comment was intentional. I think I got it from Python.
I wish the IDE reformat action would point this out, too!
Fixed to single space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No big deal, this is just not the style adopted in our library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we enforce it in automated checks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to this (and preventing merging if the style is incorrect), but only if this check doesn't make the CI fail for intermediate commits. It would be annoying to push code just to test something, without ensuring the code is pretty, only to be met with a useless style check complaint. That said, it makes sense to have this check block merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that instead of making such a check part of the regular CI pipeline, or a pre-commit hook, it could also be implemented as a GH Action, (I'm not 100% sure about this part, but) that'll report all problems right into the PR.
kotlinx-coroutines-core/wasmJs/test/PropagateExceptionFinalResortTest.kt
Outdated
Show resolved
Hide resolved
*/ | ||
@Test | ||
fun testThrows() = runTest { | ||
addUncaughtExceptionHandler() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we want to remove it afterward. Given that it doesn't seem like uncaught exceptions do anything on Wasm/JS by default, maybe it doesn't matter. Still, avoiding test cross-contamination is worth it so that this doesn't bite us when we forget about this test completely.
Fixes #4451