Close Matrix OlmMachine on shutdown to avoid napi panic - #61
Closed
strk-ai-agent wants to merge 1 commit into
Closed
Close Matrix OlmMachine on shutdown to avoid napi panic#61strk-ai-agent wants to merge 1 commit into
strk-ai-agent wants to merge 1 commit into
Conversation
The Rust OlmMachine returned by matrix-sdk-crypto-nodejs leaves
background tokio tasks pending. When the Bun process exits, the
napi-rs env cleanup hook drops the tokio runtime (RT = None) before
those tasks complete, and within_runtime_if_available panics:
panicked at .../napi-2.16.17/src/tokio_runtime.rs:114:47:
called `Option::unwrap()` on a `None` value
fatal runtime error: failed to initiate panic, error 5, aborting
matrix-bot-sdk does not expose a close hook for OlmMachine, so call
machine.close() directly from the connector's stop() path. Verified
that 'make start-matrix' now exits cleanly instead of aborting with a
core dump.
Assisted-By: MiniMax-M3 via opencode 1.18.7
Owner
|
Closing under the updated contribution policy. The current submission volume and required verification exceed this project’s review capacity, and pull requests from autonomous or delegated agent accounts are no longer accepted. Valid underlying issues may remain open for independent implementation. Please do not revise, reopen, or replace this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Rust OlmMachine returned by
@matrix-org/matrix-sdk-crypto-nodejsleaves background tokio tasks pending. When the Bun process exits, the napi-rs env cleanup hook drops the tokio runtime (RT = None) before those tasks complete, andwithin_runtime_if_availablepanics:This is the well-known race tracked upstream as napi-rs PR #3252 (still open). Since the prebuilt
.nodebinary embedsnapi-2.16.17and the upstream fix isn't released, a clean shutdown requires cancelling pending tokio work before Bun tears down the napi env.matrix-bot-sdk@0.8.0doesn't expose a close hook forOlmMachine, butOlmMachine.close()is already exported by the native binding, so this PR calls it directly from the connector'sstop()path before logging "Stopped.".Verified with a minimal repro: before the fix
make start-matrixaborts with a core dump on SIGTERM; after the fix it exits 0. Typecheck, full test suite (348 tests) and connector build check all pass.Filed on a dedicated
napi-workaroundbranch so the connector'smainstays clean while we wait for the upstream napi-rs fix and a correspondingmatrix-sdk-crypto-nodejsrelease.Assisted-By: MiniMax-M3 via opencode 1.18.7