newGig receiver loop breaks permanently after one error — later newGig events on that socket are dropped#247
Draft
JoshuaVSherman wants to merge 3 commits into
Draft
newGig receiver loop breaks permanently after one error — later newGig events on that socket are dropped#247JoshuaVSherman wants to merge 3 commits into
JoshuaVSherman wants to merge 3 commits into
Conversation
The catch block in AgController.newGig() transmitted socketError then broke out of the receiver loop, permanently killing that client socket's newGig/newTour consumer after the first error. Sibling handlers (editDoc, removeGig) already transmit-and-continue; newGig now matches that behavior. Bump 3.0.8 -> 3.0.10 (skipping 3.0.9, already claimed by PR #245/#244).
…k-loop # Conflicts: # package.json
Contributor
Author
|
⛔ Do not merge — CircleCI build 474 failed: the test suite hangs ("run all tests" timed out at 10m in |
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.
Summary
break;from thecatchblock innewGig(client, messageName)(src/AgController/index.ts) — the receiver loop was exiting permanently on the FIRST errorednewGig/newTourmessage, silently dropping every laternewGigon that same client socket (no create, nosocketError, no response).socketErrorback to the client on every error; it just no longer exits the loop, matching the existing behavior of the siblingeditDoc(editGig/editTour) andremoveGig(deleteGig/deleteTour) handlers, which already recover and keep listening after an error.newGigand the legacynewTouralias, sinceaddSocketwires both message names through this samenewGig()method.test/AgController/index.spec.ts: a single client socket receives anewGigwith invalid gig data first (throwsInvalid create gig data, assertssocketErroris transmitted), then a validnewGigsecond on the SAME consumer — assertsgigController.createDocsis still invoked for the second message. This test would hang/fail on the old code because the loop had already exited after the first error.package.jsonversion3.0.8→3.0.10(skipping3.0.9, which PR Populate linked venue on the gig feed (gig↔venue linkage) #245/Populate linked venue on the gig feed (gig↔venue linkage) #244 already claimed ondev, to avoid a version collision).Closes #246
Closes #240
How to test locally
Scenario a reviewer would actually run — two sequential
newGigtransmits on one open client socket:socketCluster.create({...})), authenticated as an admin user.newGigwith data that will fail server-side validation, e.g.:socketErrorevent with{ newGig: 'Invalid create gig data' }.newGig:gigCreatedpublish, nosocketError, no server-side log at all. The receiver loop fornewGigon that socket had already exited (break;in thecatch) after step 2, so the consumer never sees this second message.gigCreatedwith the new gig document, exactly as it would if this had been the first message on a fresh socket.newTourmessage name (addSocketwiresnewTourthrough the samenewGig()handler) — same two-step sequence, same expected before/after difference.Automated coverage of exactly this sequence lives in
test/AgController/index.spec.ts—'keeps handling newGig on the same socket after an earlier newGig errored (#246)': a single mocked receiver consumer returns an invalid-data message first (assertingsocketErrorfires), then a valid message second on the same consumer (assertinggigController.createDocsis still called).Test evidence
npm run lint(viaeslint .) — clean, 0 errors:(all 96 are pre-existing
@typescript-eslint/no-explicit-anywarnings across the codebase, unrelated to this change.)npx tsc --noEmit— clean, no output, exit 0.npm test(eslint . && npm run typecheck && rimraf coverage && npm run test:unit) full output tail:The 1 failing test/file is a pre-existing, environment-only failure unrelated to this fix:
It is caused by a
MongoParseErrorat module load (src/model/db.tstryingmongoose.connect()against thissandboxed worktree's
.env, which has no realTEST_DBcredentials) disrupting timer-based test assertions.Confirmed pre-existing and unrelated to this change by
git stash-ing this fix and re-running the identicaltest on the unmodified
devtip — it fails identically:vitest's
bail: 1config stops the whole file at this first (pre-existing) failure, so the new regression testfurther down the same file — added by this PR — could not run as part of the full
npm testinvocation. Verifiedit directly in isolation instead:
This confirms:
keeps handling newGig on the same socket after an earlier newGig errored (#246)) passes with the fix applied;socketError { newGig: 'Invalid create gig data' }transmission on the first (erroring)newGig, AND thatgigController.createDocsis still invoked for the second (valid)newGigon the same socket/consumer — the exact regression from issue newGig receiver loop breaks permanently after one error — later newGig events on that socket are dropped #246.🤖 Work by Claude Code — Sonnet 5