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
fix: crash problem with message_port close event #41201
fix: crash problem with message_port close event #41201
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
8c8b613
to
eda68ca
Compare
Thanks for the detailed context, looking at the upstream bug the close event has been enabled by default since 122. We should remove https://github.com/electron/electron/blob/main/patches/chromium/feat_add_onclose_to_messageport.patch in favor it for |
@deepak1556 Okay, so should I submit a new PR to adapt to this change? Or will other official personnel handle it? |
You can make the changes in this PR since the test you have added is good to have. So next steps would be,
|
When worker_thread shutdown, it will destory context and close message_port. In this case, it should not dispatch close event. Because it forbid script running during NotifyContextDestroyed in ContextLifecycleNotifier. Now chromium has implemented close_event and will not crash, so we remove the patch with electron#22532 and add one test.
eda68ca
to
d67d64b
Compare
@deepak1556 Thanks for your reply. I'm done. After testing, it can pass the test of 'ipc module', which means that the function of close_event is not damaged. Also, I added a test to make sure the same crash doesn't occur. |
@deepak1556 Will it automatically merge in? If not, it seems like I don't have the authority to operate it. Could you please help with the operation. |
@electron/patch-owners need another review before merging. |
@deepak1556 Thanks for your reply. @codebytere Can you help review the code? |
Congrats on merging your first pull request! 🎉🎉🎉 |
Release Notes Persisted
|
I have automatically backported this PR to "29-x-y", please check out #41237 |
in #22532 @nornagon add onclose method to MessagePort, but there is a crash scenario.
When worker_thread shutdown, it will destory context and close message_port. In this case, it should not dispatch close event. Because it forbid script running during NotifyContextDestroyed in ContextLifecycleNotifier.
We noticed that https://bugs.chromium.org/p/chromium/issues/detail?id=1495616 has started to implement the close event in Chromium, but it is not enabled by default yet. We still need to fix the crash. Once it's in a stable state we can use Chromium's implementation and remove this fix and #22532.
The crash stack is as follows:
Reproduce the crash:
// index.html
// worker.js
});
Description of Change
Checklist
npm test
passesRelease Notes
Notes: Fixed crash in MessagePort::close.