You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
otel-thread-ctx: address review feedback from #347 (#366)
* Address review feedback from PR #347
Four independently-flagged concerns:
- Accept optional third `attributes` arg in ThreadContext constructor.
The TS ThreadContextCtor.new type declares `attributes` optional, but the
C++ side hard-errored on `args.Length() != 3`. Loosen to accept 2 or 3
args; EncodeAttrs already handled undefined/null attrs_val correctly.
- Fold `cleanup_registered` into `undefined_addr`. Uses the field's zero /
non-zero state as the 'already-registered' flag: it starts at zero,
ResetDiscoveryStruct clears it back to zero (so a re-init on the same
thread would re-register), and any real V8 undefined singleton address is
non-zero. Removes the separate thread_local static.
- Coerce attribute values to strings in a pre-pass in EncodeAttrs before
writing to the output buffer. Value->ToString may execute user JS (custom
toString methods) which could re-enter into the ThreadContext via
appendAttributes and interleave with our writes. Separating the coerce
phase from the encode phase keeps the encode phase re-entrancy-free.
- Make the 'enterWithContext attaches the record to the current async scope'
test callback `async` and `await tcRun(...)`. Previously the callback
returned a promise via `void tcRun(...)` and the promise's inner `.then`
assertion could fire an unhandled rejection instead of a test failure.
* Explicitly guard against reentrant Append calls.
Also undo the two-phase encoding loop that was the previous
(insufficient) attempt at fixing the reentrancy.
0 commit comments