fix(swagger): hoist the one inline predicate that makes the generator run away
`npm run swagger` cannot run on this tree. It dies with swagger-autogen's
"FATAL ERROR: invalid array length - Allocation failed", generating
nothing, and it reproduces on a pristine checkout under both Node 20 and
Node 24 — so the committed spec cannot be regenerated by anyone, and any
PR that adds or changes a route is unable to meet the standing obligation
to update it.
Bisected to one statement in `teams.router.js`:
param('teamId').custom((v) => v === 'default' || TEAM_ID.test(v))
Hoisting that arrow to a named const fixes it outright. Nothing else
changes and the regenerated spec is byte-identical to the committed one,
so this is a generator fix, not a spec change.
The diagnosis worth keeping, because the file's own comment recorded a
different one. Phase 8 shipped a bare regex LITERAL before `.test(` and
phase 9 hoisted the regex, blaming a per-file route limit measured at
twenty statements; the file has sat at nineteen ever since on the theory
that it was one under the edge. That theory is wrong. Probing every
router file individually, `teams.router.js` at nineteen statements dies
while a THREE-route file carrying only this one route also dies — so the
trigger is the inline arrow reaching `.test(`, not the count. Hoisting
the regex was half the fix; the predicate around it needed hoisting too.
The comments in `teams.router.js`, `teamsVoice.router.js` and
`admin/index.js` are corrected to say so, since all three currently tell
the next person to keep counting statements.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -88,12 +88,13 @@ adminRouter.use('/modules', modulesRouter)
|
||||
// Voice channels (TEAMS.md §7.3, phase 9) are mounted at the more specific prefix
|
||||
// FIRST, so /teams/voice/* never reaches the teams router's `/:id`.
|
||||
//
|
||||
// They live out here rather than inside `teams.router.js` beside the bridge they
|
||||
// belong with, for a mechanical reason worth recording: that file sits exactly at
|
||||
// swagger-autogen's per-file limit. At twenty `teamsRouter.*` statements
|
||||
// `npm run swagger` dies with "invalid array length — heap out of memory"; at
|
||||
// nineteen it generates. One more statement of any shape tips it, a mount
|
||||
// included, so the mount is here and the file keeps its nineteen.
|
||||
// The voice routes live in their own file, and the mount is out here rather than
|
||||
// in that file, because phase 9 believed swagger-autogen enforced a per-file route
|
||||
// limit that `teams.router.js` was sitting on. It does not: the generator's
|
||||
// runaway is triggered by an expression reaching `.test(` inside a route
|
||||
// statement, which that file had and has since had hoisted. The arrangement is
|
||||
// kept on its own merits — voice is its own capability — but neither the split nor
|
||||
// the placement of this mount is load-bearing any more.
|
||||
adminRouter.use('/teams/voice', teamsVoiceRouter)
|
||||
adminRouter.use('/teams', teamsRouter)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user