Repository navigation
Add opt-in Event, EventTarget, CustomEvent, AbortController and AbortSignal - #3096
Merged
Merged
Conversation
…Signal Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011G7Ud48VAs1JicxRZxLDxg
Evaluate itself pumps the event loop, so asserting a real 1ms timeout signal has not yet aborted races the machine: a loaded runner passes more than a millisecond before the read and the signal has legitimately fired, which is exactly what three CI legs demonstrated. A held manual clock makes the not-yet half a fact and an advanced one makes the fired half deterministic. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the opt-in web API series (#3079):
Event,CustomEvent,EventTarget,AbortControllerandAbortSignalbehindWebApiFeatures.Events(inDefault). These are prerequisites for fetch's cancellation model. Usual rules: BCL only, net8+, opt-in, default engine unchanged.Dispatch is flat, and deliberately runs both passes. The DOM standard's dispatch walks an event path built from a node tree; author-created
EventTargets have no tree, so the path is the single item «target» — and everything that survives that reduction is the real algorithm, not an approximation: both passes still run witheventPhaseatAT_TARGET, socapturedecides which pass a listener runs in (a capturing listener on a flat target runs before a non-capturing one whatever order they were registered — the standard's own behavior, pinned);stopPropagationends the dispatch after the current pass whilestopImmediatePropagationalso breaks out of it; each pass walks a clone so a listener added mid-dispatch does not run and one removed does not either;oncelisteners are removed before invocation so a throwing callback cannot run twice.A listener that throws erupts from
dispatchEvent— the spec's "report the exception" presumes areportErrorchannel that does not exist yet, and swallowing would lose the error entirely on a console-less engine; so it propagates, matching the timer-callback contract, with dispatch state unwound in afinally. WhenreportErrorlands this becomes report-and-continue behind the sink.AbortSignal is fetch's cancellation seam. Abort algorithms run before the
abortevent — the engine's own algorithm (cancelling the signal's lazily-createdCancellationTokenSource) runs first of all, so a CLR-side operation stops before any script observes the abort.AbortSignal.timeout(ms)schedules on the timer queue (fires only while pumped, counts againstMaxActiveTimers,[EnforceRange]semantics);AbortSignal.anyimplements dependent signals with source flattening and link-dropping on abort so an aborted signal retains nothing;addEventListener'ssignaloption unregisters on abort, andremoveEventListeneralso takes the algorithm off the signal — avoiding a retention the spec itself leaves behind. The events feature creates the per-engine web-API state even without the timers flag, becauseEvent.timeStampreads the shared time origin andAbortSignal.timeoutneeds the queue.162 new tests. Documented WebIDL simplifications follow the series' precedent (non-enumerable prototype operations; strong rather than weak dependent-signal lists, with the trade-off explained on the type). Verified: all-TFM build, both suites both frameworks, both host-contract-verification configurations.
🤖 Generated with Claude Code