fix(game): numbered name fallback when pool exhausted — server no longer freezes past 128 systems
CI / build + unit + e2e (pull_request) Successful in 2m38s
CI / build + unit + e2e (pull_request) Successful in 2m38s
Production freeze reported after the v0.9.3 (#21) deploy: every API route hung and all panels stayed at LOADING. Root cause was not the #21 layout (verified healthy across all 7 tabs/viewports) but makeName's unbounded rejection loop over a finite 16x8=128 system-name pool — once a save grew past ~128 systems, any jump into an undiscovered system spun forever on Node's single thread (sql.js is synchronous), blocking the whole process. makeName and makeCrewName now fall back to numbered variants ('Kepler Drift 2') once their pools are exhausted, so they always terminate.
This commit is contained in:
@@ -71,4 +71,17 @@ describe('makeCrewName', () => {
|
||||
for (let i = 0; i < 40; i++) makeCrewName(rng, taken)
|
||||
expect(taken.size).toBe(40)
|
||||
})
|
||||
|
||||
it('terminates with numbered variants once all 352 base names are taken', () => {
|
||||
const rng = startingCrewRng('7')
|
||||
const taken = new Set<string>()
|
||||
for (let i = 0; i < 352; i++) makeCrewName(rng, taken) // exhaust the whole pool
|
||||
expect(taken.size).toBe(352)
|
||||
|
||||
const a = makeCrewName(rng, taken) // must return instead of spinning forever
|
||||
const b = makeCrewName(rng, taken)
|
||||
expect(a).not.toBe(b)
|
||||
expect(taken.has(a)).toBe(true)
|
||||
expect(taken.has(b)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user