Repository navigation
feat(net)!: @moq/net requests are awaitable, and its last odd names match Rust - #8953
Conversation
Quest-Claim: 2e6aee30d4faba44
…and closed fields are GetPromise Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inish the quest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…luded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 5 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed all 29 files: the @moq/net API reshaping, the origin shutdown fix, and the call sites and tests updated to match.
Origin.Requestingis awaitable. A memoizedthengetter resolves onceactiveholds a broadcast. It rejects with the errorclosedcarries, or withStreamCode.Cancelwhen the request closes cleanly, so anawaitnever hangs.Producer.close()ends every open request. Handles in both joined and detached slots settle withabort ?? null. Apeek()guard protectsOnce.set, and since both tables are cleared first,drop()can no longer reach these slots and settle them twice.delay→backoff. The rename coversConnection.Props,ReloadDelay/Backoff,DEFAULT_BACKOFF, the share refusal, and every test. The other two meanings ofdelayare untouched.closedfields areGetPromise<Error | null>. Both session classes settle aOncefrom aquic.closedreaction registered after auth'sleave, so the old ordering holds.IssuedGrant.endednow reads thatOnce.- Wait loops replaced with
await. I checked the loops that remain intest/interop/clients/js-native/*andjs/crypto: every one is onfollow().@moq/watchnever passes aRequestingthrough promise resolution, so it won't unwrap the handle by accident. datagram-tracksassertion. The test now matchesTimestamp.unscaled(sequence), which makesscaleundefined andvalueequal to the sequence.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed fc9794630f6fe45b86d73979b9c36c49f26023f0. Awaiting a request is an improvement, but P2: reading request.then alone can produce an unhandled rejection (js/net/src/origin.ts:2113). A common thenable check like typeof request.then === "function" creates the memoized promise without attaching a handler; if the request is closed or later refused, that check alone can kill a Node process in strict mode. Either start the memo when the returned function is invoked, or attach a rejection observer to the memo without changing the result that real awaiters receive. I reproduced the unhandled-rejection pattern in a minimal Node fixture, not the full package.
Also put teardown in finally in js/net/examples/subscribe.ts: a missing broadcast now rejects before the connection and origin close, so the example can still leave a live transport after logging the error. Show a retained request in the class JSDoc too, rather than await origin.request(...), since only the request can release its discovery watch.
|
Maintainer decision (2026-11-16, /quest-run)
(Written by Opus 5.5) |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the last review at fc97946, Requesting stopped being a thenable and gained an explicit broadcast() method, and the call sites now use it. The rest of this delta comes from merging main.
Requesting.broadcast()replaces thethengetter. It keeps the same memoizedanswer(active, closed), andPromiseLikeand thebiome-ignoreare gone. This also removes the earlier risk of an unhandled rejection when code only checked for.then: the memo now starts only when a caller invokesbroadcast(), and that caller gets the promise back.- Call sites moved to
await request.broadcast(). This covers the example,bench/refresh.ts,compression.test.ts,refresh.test.ts, and the audio-quality, datagram-tracks, max-age, stream-credit, and stream-limits clients. I searched for anyawait requestleft on aRequestinghandle. The only two hits are inrequest-deadline.test.tsandlite/publisher.test.ts, and both await unrelated promises. - Tests track the new shape. A new test checks that the handle has no
thenand that returning it from anasyncfunction gives back the same handle. The first-call memo test and the shutdown tests now callbroadcast(). - The doc, the JSDoc and the API report match
broadcast(). They say the handle is not awaitable and that the request still owns the broadcast.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed 537de6e5fbc130d7e092c427fa3af1e8281e0fb4. The explicit request.broadcast() method fixes the previous thenable bug: inspecting or returning the handle no longer allocates a promise or assimilates the broadcast. The revised tests cover success, refusal, clean cancellation, and repeated calls, and the JSDoc keeps the owning handle. No new implementation blocker. The earlier example-cleanup point remains: if broadcast() rejects, js/net/examples/subscribe.ts still skips teardown; close the request, connection, and origin in finally. Static inspection only; I didn’t run the JS tests.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the last review at 537de6e, the only new commit merges main. That merge changes nothing in the PR's code.
- Resolved a conflict in the
quest/m2/README.mdmerge. The "JS and browser" line now links onlysignals. Thejs-net-api.mdlink is gone, which matches this PR deleting that quest file.
claude-opus-5-5 | 𝕏

Finishes
quest/m2/js-net-api.md(deleted here).Problem
Three
@moq/netshapes disagreed with Rust and with the package's own rules before the 0.22 cut freezes them:origin.request(path)had no await. The hello world (js/net/examples/subscribe.ts) looped onactive.changed()and hung forever when the broadcast did not exist, because a refusal settlesclosedand leavesactiveundefined.Connection.Props.delay, while Rust, moq-tokio, and moq-ffi saybackoff, anddelayalready means two other things in this package.Connection.Session.closedwas a mutablePromiseandAuth.Credential.closedaPromiseLike, againstjs/AGENTS.md's rule that terminal state is aGetPromise<Error | null>.Approach
Origin.Requesting.broadcast()returns a promise that resolves onceactiveholds a broadcast, or rejects with the errorclosedcarries if the request ends first (such asUnroutable). Whenclosedsettlesnull(the handle or its origin closed cleanly), it rejects with aStreamCode.Cancelerror, so an await never hangs. The first call fixes the answer, and later calls return the same promise.Requestingis not a thenable: anawaitor anasyncreturn of the handle never takes the broadcast out from under the request that owns it (maintainer decision, below).active,closed, andclose()are unchanged.Followingstays a plain handle, since it never settles.Connection.Props.delayisbackoff. The internalReloadDelaytype isBackoff(matching itsConnection.Backoffexport),DEFAULT_DELAYisDEFAULT_BACKOFF, and the share refusal reads "backoff cannot be shared".WebSocketProps.delayandTrack.Subscription.delayare untouched.Connection.Session.closedisreadonly closed: GetPromise<Error | null>. Both session classes settle oneOncefrom the transport's close, after auth has let go of the session, as the old getter did.Auth.Credential.closed, plus the@internalAuth.Issued.closedandAuth.Request.closed, areGetPromise<Error | null>too.IssuedGrant.endednow reads itsclosedinstead of keeping a second flag.request()wait loops nowawait request.broadcast(): the example,js/net/bench/refresh.ts, twojs/nettests, and the audio-quality, stream-limits, datagram-tracks, max-age, and stream-credit clients.doc/lib/js/net.mddocuments it.null. Before,Producer.close()cleared the request table without settling a pending request'sclosed, which the doc promised, so anawaiton it would have hung (found by review).test/datagram-tracks/client.tsexpected an untimed datagram to have no timestamp. Since moq-dev/moq#8638, it carriesTimestamp.unscaled(sequence). The nightly-only lane failed onmain, and this PR fixes the assertion.Impact
Public API, breaking for
@moq/net. Wire: none. Bindings: none (Rust and moq-ffi already saybackoffand await a request).Migration:
new Connection({ delay: { ... } })→new Connection({ backoff: { ... } }). The fields (initial,multiplier,max,healthy,timeout) are unchanged. Ashare: trueconnection givenbackoffthrows "backoff cannot be shared; pass share: false".await request.broadcast(). The await rejects when the request ends without a broadcast, where the loop hung:session.closedandcredential.closedare nowGetPromise<Error | null>.awaitand.thenwork as before. Code that typed them asPromise<Error | null>(for example, a mockSessionorCredential) builds aOnce<Error | null>from@moq/signalsinstead.session.closedisreadonly.Requestingis not awaitable: pass the handle throughasyncfunctions and promise resolution freely, and callbroadcast()when you want the broadcast.Decisions
Maintainer decision (2026-11-16, /quest-run, comment): merge once
Requestingstops being a thenable. It gains an explicitbroadcast()method with the same resolve and reject behavior, which keeps the request owning the broadcast and keeps an async function or promise resolution from silently awaiting the handle. The example, docs, tests, and API report follow it. Thedelaytobackoffrename andclosedasGetPromise<Error | null>are accepted as they were. This supersedes the earlier thenable shape (and the earlier decision 2's "firstthenread").The rest were taken while the maintainer was away, and the maintainer accepted them with that comment:
StreamCode.Cancel(message "request closed"). The quest recommended one named cancellation error.StreamCode.Cancelalready exists, and Rust'sError::Closedmaps to it, so no new export is needed. Alternative: a newError.Cancelledclass.broadcast()call, not tracked from construction. Tracking from construction would subscribe on every request, including the onesfollow()makes internally, for an answer few callers read. A lazy answer also avoids an unhandled rejection nobody awaits. The cost: a request that resolved and then ended before anyone awaited it rejects with the ending. Alternative: track from construction and resolve with the first broadcast ever held.active, closed with the request. Rust drops theRequestingon await, but in JS the request drives failover between routes of the same instance, so releasing it on resolve would lose that. The example, thebroadcast()doc, and the net docs say to close the request. Alternative: release the request on resolve and return a clone, losing failover.Auth.Issued.closedandAuth.Request.closedtook the same type. The quest recommended this but left it open. Both are@internaland were the only otherPromiseLiketerminal fields.follow()stay, since a follower never settles.test/smoke/clients/js-native/subscribe.tsandtest/interop/compat/client.tsstay because they run against the published@moq/net, which has nobroadcast()yet, and both follow. The quest named the smoke client, but that predates checking what it runs against.claims.tsandreplace.tsreadFollowinghandles, or both shapes.js/net/MIGRATE.mdedit. The quest's Plan asked for one, but CONTRIBUTING and RELEASE have the release cut writeMIGRATE.mdfrom each PR's Impact section.Overlap with open PRs
pool.tsnear the renamed option, and reads credentialclosedthroughthen, whichGetPromisekeeps.quest/m2/README.mdline.Validation
https://cdn.moq.dev/anon(WebSocket, moq-lite-06) awaitedorigin.request()for a random missing path. It rejected after 51 ms withStream: unroutable(code === StreamCode.Unroutable). The old example loop hangs in that case. Againsthttps://cdn.moq.dev/demo, it awaited a request for the first announced broadcast (bbb.hang), resolved, and read its 829-byte catalog.just test max-age,just test stream-limits, andjust test datagram-trackspass. All three useawait request.broadcast()now, rerun after the maintainer's change. Before the assertion fix,datagram-tracksgot past the await and failed on the stale timestamp check, which is a failure onmaintoo.js/net/src/origin-request.test.ts: awaitingbroadcast()for a missing path rejectsUnroutableonce discovery syncs; it resolves at once when routed and later when a route arrives; closing a pending request, or requesting on a closed origin, rejectsCancel; closing an origin rejects a pending await with its abort (orCancelwhen clean) and ends a resolved request, which timed out before the fix; the first call fixes the answer; aRequestinghas nothenand survives an async return. To check that the tests discriminate, I dropped the memo (??=→=), and "the first call fixes a request's answer" failed (before thebroadcast()change). The real-relay script above ran on the thenable shape; the Rust-relay clients were rerun onbroadcast().just checkpasses: biome, every JS build including the API report and the doc site, and the JS tests (rerun after merging main and thebroadcast()change). The standalonetest/{stream-limits,max-age,datagram-tracks}clients also type-check withtsc.Caused by
moq-dev/moq#8638: gave every datagram a timestamp (unscaled at its sequence when untimed) but left
test/datagram-tracks/client.tsassertingundefined(found by check)No single PR:
Producer.close()never settled a pending request'sclosed, though its doc has promised "origin shutdown" since the request handle split fromfollow()in moq-dev/moq#7476, and the wording predates that (found by reviewer)Follow-ups
None.
Models
Size: M
Implementer: Claude, claude-opus-5-5, high effort (arm B)
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (iterate, M)
(Written by Claude Opus 5.5 with high effort)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 5280af6
Base: origin/main at 8fbbb2a
Risk: high,
The branch changes public @moq/net APIs that downstream applications depend on, so consumers may require source updates even though the repository changes are reversible.Classified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1e962-1ddb-7e00-b258-e578c88dd101, round 2Score: 9/10,
The incremental merge introduces no actionable findings beyond the previously reviewed change; builds and tests were not run, as requested.Raised the risk to high:
The branch changes public @moq/net APIs that downstream applications depend on, so consumers may require source updates even though the repository changes are reversible.Rounds: 4; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none