Skip to content

Add WorkerTracer::hasTailStreamWriter() - #8263

Merged
dom96 merged 1 commit into
mainfrom
dominik/tracer-has-tail-stream-writer
Nov 10, 2026
Merged

dom96 merged 1 commit into
mainfrom
dominik/tracer-has-tail-stream-writer

Conversation

@dom96

@dom96 dom96 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Lets the embedder tell whether an invocation's events are streamed to tail workers, e.g. to start continuous profiling only on invocations that produce a Workers trace.

@dom96
dom96 requested review from a team as code owners November 6, 2026 16:29

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 9dc7fae8.

This review, of 47d2109a

✅ Approved — Trivial const accessor over an existing member; no issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

WorkerTracer::hasTailStreamWriter() is a const accessor over maybeTailStreamWriter and is placed in the public section. No issues.


Reviewed commit: 47d2109a

@codecov-commenter

codecov-commenter commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.28%. Comparing base (68d62dd) to head (8fd0a27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8263   +/-   ##
=======================================
  Coverage   65.28%   65.28%           
=======================================
  Files         758      758           
  Lines      191103   191103           
  Branches    30169    30169           
=======================================
+ Hits       124760   124762    +2     
  Misses      48809    48809           
+ Partials    17534    17532    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dom96
dom96 force-pushed the dominik/tracer-has-tail-stream-writer branch from 47d2109 to 9dc7fae Compare November 9, 2026 12:46

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of e92a0d18.

This review, of 9dc7fae8

✅ Approved — Trivial const accessor over an existing member; no issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

WorkerTracer::hasTailStreamWriter() is a const accessor over maybeTailStreamWriter and is placed in the public section. No issues.


Reviewed commit: 9dc7fae8 — same changes as 47d2109a, so this is that commit's review (no new review was run; line numbers are as of 47d2109a)

@dom96
dom96 force-pushed the dominik/tracer-has-tail-stream-writer branch from 9dc7fae to e92a0d1 Compare November 9, 2026 15:46

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 735c9a08.

This review, of e92a0d18

💬 Approved with comments — The code changes look correct and are covered by tests. The one remaining point is a developer reference doc that no longer matches the new deferred-linking and cycle-rejection behaviour in the legacy module registry.

Findings: 1 warning

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.

🔧 Fix with your agent

Paste the following into your coding agent to investigate and fix these issues.

Fix the following code review issues found in pull request #8263.

Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
  for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

## WARNING (1)

### [Documentation] The legacy module registry reference still says the resolver always returns the module and that a dynamic import always instantiates inline and returns the namespace right away. It does not mention the new `kEvaluating` rejection or the deferred linking.
- **File:** docs/reference/detail/legacy-module-registry.md:295

📝 Documentation: ⚠️ 1 warning

The legacy module registry reference doc no longer matches the new resolve and dynamic-import behaviour.

Recommendation: 📝 Minor Comments

  • [WARNING] The legacy module registry reference still says the resolver always returns the module and that a dynamic import always instantiates inline and returns the namespace right away. It does not mention the new kEvaluating rejection or the deferred linking. (docs/reference/detail/legacy-module-registry.md:295)
View full review

docs/reference/detail/legacy-module-registry.md still describes the old flow:

  • The resolve callback (around line 214) always returns the resolved module's handle.
  • The dynamic import path (around lines 291-295) calls instantiateModule and returns module->GetModuleNamespace() right away.

With this change, the resolver rejects a module that is still kEvaluating, and a nested dynamic import can defer linking to a microtask and read the namespace only after that work settles. Updating the resolve-callback, dynamic-import and instantiateModule sections would keep the reference accurate.


✅ All other checks passed

🔒 Security: ✅ LGTM

The StdioFile::write fix closes a use-after-free: user code running inside console.log could detach, transfer or shrink the ArrayBuffer being written. The module-linking change replaces a process abort with a JS error. Neither change opens a new trust-boundary or memory-safety problem.


📖 AGENTS.md: ✅ LGTM

No AGENTS.md updates are needed for this change.


📋 Code Quality: ✅ LGTM

Module linking (jsg/modules.c++):

  • The new kEvaluating guard in resolveModuleCallback only fires when a graph is linked while one of its modules is still evaluating. Ordinary static cycles are not affected.
  • Deferral only happens for a nested import that allows a pending result. require() and the main module still link synchronously and throw on failure.
  • The retried link in the microtask rejects the import with the module's own error.

Namespace read (jsg/modules.h): The namespace is read only once the pending promise settles, which is required because an unlinked module has no namespace yet.

Stdio write (worker-fs.c++): StdioFile::write copies the caller's buffer before re-entering JS. The final buffer.size() only reads the view's size field, not the bytes it points to.

Tests: The new tests cover each new path.


⚡ Performance: ✅ LGTM

  • The per-write copy in StdioFile::write is linear in the write size and small next to the console.log call it guards.
  • The status check in resolveModuleCallback is O(1).
  • The deferred link path is rare and costs one microtask.

Reviewed commit: e92a0d18

@dom96
dom96 force-pushed the dominik/tracer-has-tail-stream-writer branch 2 times, most recently from 9dc7fae to 735c9a0 Compare November 9, 2026 17:20

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 8fd0a277.

This review, of 735c9a08

✅ Approved — Small, correct const accessor with no issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

hasTailStreamWriter() is a const accessor that compares the kj::Maybe writer member against kj::none. It matches the existing comparison in tracer.c++.


Reviewed commit: 735c9a08

@dom96 dom96 closed this Nov 9, 2026
@dom96 dom96 reopened this Nov 9, 2026
Lets the embedder tell whether an invocation's events are streamed
to tail workers, e.g. to start continuous profiling only on
invocations that produce a Workers trace.
@dom96
dom96 force-pushed the dominik/tracer-has-tail-stream-writer branch from 735c9a0 to 8fd0a27 Compare November 10, 2026 10:08

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — Small, correct const accessor with no findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

hasTailStreamWriter() is a const accessor over the kj::Maybe tail stream writer member. The comparison against kj::none is valid and has no side effects.


Reviewed commit: 8fd0a277

@dom96
dom96 merged commit 46a7d71 into main Nov 10, 2026
23 of 24 checks passed
@dom96
dom96 deleted the dominik/tracer-has-tail-stream-writer branch November 10, 2026 10:57
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.

4 participants