Skip to content

fix: prevent shared Option causing race by switching to value instead of pointer#21

Merged
ngocphuongnb merged 1 commit into
masterfrom
fix.isolate_option_per_runtime
Oct 20, 2025
Merged

fix: prevent shared Option causing race by switching to value instead of pointer#21
ngocphuongnb merged 1 commit into
masterfrom
fix.isolate_option_per_runtime

Conversation

@ngocphuongnb
Copy link
Copy Markdown
Contributor

Pool creation used *Option, causing all runtimes to share the same Option.ProxyFunction. ProxyFunction is created using the runtime-specific registry:

if option.ProxyFunction == nil {
    option.ProxyFunction = createFuncProxyWithRegistry(registry)
}

As a result:

  • All runtimes reused the same ProxyFunction.
  • JS functions failed to call properly because the Go function was registered in a different runtime’s proxyRegistry.

Fix:
Replace *Option with Option (value type) to ensure each runtime gets its own ProxyFunction bound to the correct registry.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.74%. Comparing base (d34497f) to head (903b8b5).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
- Coverage   99.74%   99.74%   -0.01%     
==========================================
  Files          15       15              
  Lines        3579     3576       -3     
==========================================
- Hits         3570     3567       -3     
  Misses          5        5              
  Partials        4        4              
Files with missing lines Coverage Δ
options.go 100.00% <100.00%> (ø)
proxy.go 100.00% <ø> (ø)
runtime.go 98.78% <100.00%> (-0.01%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ngocphuongnb ngocphuongnb merged commit 7f40363 into master Oct 20, 2025
20 checks passed
@ngocphuongnb ngocphuongnb deleted the fix.isolate_option_per_runtime branch October 20, 2025 05:17
c4milo pushed a commit to c4milo/qjs that referenced this pull request Nov 19, 2025
…er_runtime

fix: prevent shared Option causing race by switching to value instead of pointer
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.

1 participant