Skip to content

Retire the TS_EVENT_SOURCE autogate - #8695

Merged
jasnell merged 1 commit into
mainfrom
jasnell/retire-ts-event-source
Nov 20, 2026
Merged

jasnell merged 1 commit into
mainfrom
jasnell/retire-ts-event-source

Conversation

@jasnell

@jasnell jasnell commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Remove the C++ EventSource implementation

@jasnell
jasnell requested review from a team as code owners November 19, 2026 22:05
@jasnell
jasnell requested review from a team and edmundhung November 19, 2026 22:05

@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 50838b6a.

This review, of bc31ddb7

✅ Approved — This is a clean removal of a fully rolled-out autogate and the C++ EventSource. The TypeScript global is installed the same way as before, the types are hand-declared, and no issues were found.

Not opened by the correctness review: 4 changed files it was meant to read
  • types/generated-snapshot/experimental/index.d.ts
  • types/generated-snapshot/experimental/index.ts
  • types/generated-snapshot/index.d.ts
  • types/generated-snapshot/index.ts

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


✅ All checks passed

🔒 Security: ✅ LGTM

No security concerns. This change removes code and adds no new trust boundary or input-handling path.


📖 AGENTS.md: ✅ LGTM

The updated test-suite AGENTS.md files match the simplified layout of the test suite.


📋 Code Quality: ✅ LGTM

No issues found. All references to the C++ EventSource and the autogate are removed, the TypeScript global is installed the same way as before, and the hand-written type declarations replace the generated ones.


⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: bc31ddb7

Comment thread src/tests/events/AGENTS.md Resolved

@npaun npaun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pretty straightforward deletion

@jasnell
jasnell force-pushed the jasnell/retire-ts-event-source branch from bc31ddb to 50838b6 Compare November 19, 2026 23:12

@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 a98f83bc.

This review, of 50838b6a

✅ Approved — This pull request cleanly retires a fully rolled-out autogate and removes the C++ EventSource. The TypeScript global is installed the same way as before, and the hand-written types match the updated snapshots. No issues were found.

Not opened by the correctness review: 4 changed files it was meant to read
  • types/generated-snapshot/experimental/index.d.ts
  • types/generated-snapshot/experimental/index.ts
  • types/generated-snapshot/index.d.ts
  • types/generated-snapshot/index.ts

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


✅ All checks passed

🔒 Security: ✅ LGTM

This change only removes code. It adds no new trust boundary or input-handling path.


📖 AGENTS.md: ✅ LGTM

The updated test-suite AGENTS.md files match the simplified layout of the EventSource tests. The discussion on src/tests/events/AGENTS.md asked whether that guidance belongs in a higher-level directory. The author has said it will move as the work continues, and the file is accurate as written.


📋 Code Quality: ✅ LGTM

This is a clean retirement of the TS_EVENT_SOURCE autogate.

  • No leftover references: nothing in the tree still uses eventsource.h, api::EventSource or TS_EVENT_SOURCE.
  • Global installation: src/per_isolate/main.ts now installs the TypeScript global unconditionally. It is the old gated block with the guard removed, and the property attributes are the same.
  • Types: types/defines/eventsource.d.ts keeps the EventSourceEventSourceInit name. The EventSource: typeof EventSource override in global-scope.h keeps the global typed now that the C++ nested type is gone.
  • Generated snapshots: the regenerated types/generated-snapshot/ files move the declaration to the hand-written block. They match the new defines file.

⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 50838b6a

@jasnell
jasnell added this pull request to stack #8698 November 19, 2026 23:56
The TS_EVENT_SOURCE autogate has fully rolled out. This removes the
gate and the C++ EventSource in api/eventsource.{h,c++}, leaving the
TypeScript class (src/per_isolate/eventsource/) as the only
implementation. Configs that still name the gate are unaffected:
unknown autogate names are ignored.

Every Worker now gets the class the gate gave, with the differences
from the C++ one that the suite's divergence ledger recorded and the
rollout accepted:

- The constructor inherits from EventTarget's, its `prototype` is
  non-writable, and calling it without `new` throws the language's
  TypeError.
- The event stream is parsed as the HTML standard specifies: an empty
  `event` field dispatches a 'message', a BOM split across chunks is
  stripped, an `id` field containing U+0000 is ignored, a `retry`
  field counts only if it is all ASCII digits, a `data` field with an
  empty value dispatches empty data, a CRLF split across chunks ends
  one line, and a reconnection sends the last dispatched event's ID.
- A listener that closes the EventSource drops the rest of the
  messages read with that one, and closing an EventSource.from()
  source cancels its stream.
- A reconnection's Last-Event-ID is trimmed of HTTP whitespace.

The change itself:

- main.ts loads the module and defines the global in every context,
  as it did with the gate on, where JSG_NESTED_TYPE defined the C++
  class.
- EW_EVENTSOURCE_ISOLATE_TYPES and workerd/api/eventsource.h are gone;
  an embedder that lists the types or includes the header must drop
  them.
- With no C++ class to describe it, the TypeScript declaration moves
  to types/defines/eventsource.d.ts, and ServiceWorkerGlobalScope
  names it through its override. The generated declarations are
  unchanged but for their order and the defines file's comment.
  types/test/types/eventsource.ts covers them.
- src/tests/events/eventsource/ collapses to one set of cells:
  which-impl.js becomes flags.js, each branch keeps its TypeScript
  side, and the divergence ledger folds into the suite's
  specification. src/tests/events/AGENTS.md describes what retiring a
  gate does to a suite. eventsource-test.c++, a unit test of the C++
  class's native pump, goes with it.
- The eventsource WPTs that failed only with the C++ class now pass.
  format-field-event-empty.any.js, which hung with it, now runs, and
  fails as format-field-event.any.js does.
- Comments that compared the TypeScript implementation with the C++
  one now describe it on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasnell
jasnell force-pushed the jasnell/retire-ts-event-source branch from 50838b6 to a98f83b Compare November 20, 2026 00: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.

✅ Approved — This pull request cleanly retires a fully rolled-out autogate and removes the C++ EventSource. The TypeScript global is installed the same way as before, and the hand-written types match the updated snapshots. No issues were found.

Not opened by the correctness review: 4 changed files it was meant to read
  • types/generated-snapshot/experimental/index.d.ts
  • types/generated-snapshot/experimental/index.ts
  • types/generated-snapshot/index.d.ts
  • types/generated-snapshot/index.ts

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


✅ All checks passed

🔒 Security: ✅ LGTM

This change only removes code. It adds no new trust boundary or input-handling path.


📖 AGENTS.md: ✅ LGTM

The updated test-suite AGENTS.md files match the simplified layout of the EventSource tests. The discussion on src/tests/events/AGENTS.md asked whether that guidance belongs in a higher-level directory. The author has said it will move as the work continues, and the file is accurate as written.


📋 Code Quality: ✅ LGTM

This is a clean retirement of the TS_EVENT_SOURCE autogate.

  • No leftover references: nothing in the tree still uses eventsource.h, api::EventSource or TS_EVENT_SOURCE.
  • Global installation: src/per_isolate/main.ts now installs the TypeScript global unconditionally. It is the old gated block with the guard removed, and the property attributes are the same.
  • Types: types/defines/eventsource.d.ts keeps the EventSourceEventSourceInit name. The EventSource: typeof EventSource override in global-scope.h keeps the global typed now that the C++ nested type is gone.
  • Generated snapshots: the regenerated types/generated-snapshot/ files move the declaration to the hand-written block. They match the new defines file.

⚡ Performance: ✅ LGTM

No performance concerns.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: a98f83bc — same changes as 50838b6a, so this is that commit's review (no new review was run; line numbers are as of 50838b6a)

@jasnell
jasnell merged commit 7c4518f into main Nov 20, 2026
23 checks passed
@jasnell
jasnell deleted the jasnell/retire-ts-event-source branch November 20, 2026 06:40
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