Skip to content

fix(engine): isolate each event dispatch snapshot - #2013

Merged
joeykchen merged 1 commit into
goplus:devfrom
joeykchen:fix/event-dispatch-snapshot-ownership
Sep 28, 2026
Merged

joeykchen merged 1 commit into
goplus:devfrom
joeykchen:fix/event-dispatch-snapshot-ownership

Conversation

@joeykchen

Copy link
Copy Markdown
Contributor

A callback that synchronously triggers its own event can overwrite the outer dispatch's shared callback arrays, causing duplicate callbacks and a nil-call panic. Concurrent triggers also race on those arrays. Give each dispatch an ordered callback snapshot captured under the mutex, then invoke it after unlocking.

The cleanup pass shares the snapshot operation across all three event arities and removes persistent scratch buffers, their cleanup helper, unused state and redundant constructor initialization. Subscription order and changes during dispatch retain their existing semantics.

Validation:

  • Reentrant regressions fail on the old implementation and pass for Event0, Event1 and Event2.
  • Callback mutation, panic recovery and concurrent dispatch tests pass; the engine event package passes the race detector.
  • Runtime consumer tests, pure-engine checks and root wasm compilation pass; runtime output is regenerated twice for consistency.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete fixed diff for the event snapshot ownership change, including reentrant dispatch, subscription mutation, panic recovery, concurrent triggers, and the generated type snapshot. No actionable correctness or regression findings remain. Verified with go test ./pkg/spx/pkg/engine, go test -race ./pkg/spx/pkg/engine, and go test ./pkg/spx/....

@joeykchen
joeykchen force-pushed the fix/event-dispatch-snapshot-ownership branch from 960198e to a39c896 Compare September 28, 2026 04:28
@joeykchen
joeykchen merged commit e8a8863 into goplus:dev Sep 28, 2026
9 checks passed
@joeykchen
joeykchen deleted the fix/event-dispatch-snapshot-ownership branch September 28, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants