Skip to content

chore(devops): turn on no-floating-promises for src/server - #6101

Merged
evanpelle merged 1 commit into
openfrontio:mainfrom
wraith4081:chore/oxlint-server-floating-promises
Oct 23, 2026
Merged

evanpelle merged 1 commit into
openfrontio:mainfrom
wraith4081:chore/oxlint-server-floating-promises

Conversation

@wraith4081

@wraith4081 wraith4081 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Description:

Turns on typescript/no-floating-promises for src/server only. The client has 162 hits across 47 files (mostly Lit event handlers) and the engine has none, so this starts where a dropped promise matters most and the count is small: 4 hits.

One of them was a real mistake. GameManager wrapped game.end() in try/catch, but end() is async, so the catch never ran. A failure there skipped the "error ending game " log and only reached the worker's generic unhandledRejection handler, without the game ID. It now uses .catch().

The other three are fire-and-forget on purpose and just get void:

  • GameServer's partial-record archive(), which handles its own failures (Archive.ts)
  • the replay chain in WinnerReplayChild
  • privilegeRefresher.start() in Worker

Heads-up:

  • The quickest way to silence this rule is void. In server code, prefer await or .catch() with a log whenever the caller would want to know about a failure; void is only for genuine fire-and-forget.
  • The rule only covers src/server. Server-side code in packages/shared isn't checked.
  • Errors from ending a game are now logged as "error ending game " instead of "unhandled rejection". Any alert keyed on the latter won't see this path anymore.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory

Please put your Discord username so you can be contacted if a bug or regression is found:

wraith4081

@wraith4081

Copy link
Copy Markdown
Member Author

/ready

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: efc52179-c3cb-4389-82bb-95ede103cf2b
📥 Commits

Reviewing files that changed from the base of the PR and between ab6ca3f and cb13117.

📒 Files selected for processing: 5
  • .oxlintrc.json
  • src/server/GameManager.ts
  • src/server/GameServer.ts
  • src/server/WinnerReplayChild.ts
  • src/server/Worker.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Walkthrough

The server TypeScript lint configuration now treats floating promises as errors. Several server call sites explicitly discard promises, and GameManager.tick logs rejections from game.end(). Synchronous exceptions from calling game.end() are no longer caught there.

Changes

Server promise handling

Layer / File(s) Summary
Enforce and handle server promises
.oxlintrc.json, src/server/GameManager.ts, src/server/GameServer.ts, src/server/WinnerReplayChild.ts, src/server/Worker.ts
The server TypeScript override enables typescript/no-floating-promises as an error. GameManager.tick logs rejected game.end() promises. Other call sites explicitly discard promises returned by deps.archive, replay(req), and PrivilegeRefresher.start().

Priority: ⚪ Not assessed

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested labels: ready-for-review

Suggested reviewers: celant

Merge Risk: ⚪ Minimal · up to cb131

The change enables server promise checks and adds game-specific failure logging without an established behavioral regression. It is ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: enabling no-floating-promises for src/server.
Description check Passed The description directly explains the rule change, the affected files, the promise-handling fixes, and the intended fire-and-forget calls.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

A promise starts its server flight
One rejection gets a log
Some promises are set aside
A lint rule keeps them in sight
The tick moves on through the fog

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Verdict: Looks good — 0 findings (0 high, 0 medium, 0 low).

No issues found. Checked for bugs and CLAUDE.md compliance.

  • GameManager: GameServer.end() is async, so the old try/catch could never catch its rejections; .catch() with the game ID is correct.
  • The three void sites are genuinely fire-and-forget: archive() catches its own failures (Archive.ts), PrivilegeRefresher.start() only logs and calls startPolling, and the WinnerReplayChild chain already turns rejections into a ReplayResponse.

@evanpelle evanpelle added this to the v36 milestone Oct 23, 2026

@evanpelle evanpelle left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@github-project-automation github-project-automation Bot moved this from Triage to Final Review in OpenFront Release Management Oct 23, 2026
@evanpelle
evanpelle merged commit 7252127 into openfrontio:main Oct 23, 2026
16 of 19 checks passed
@github-project-automation github-project-automation Bot moved this from Final Review to Complete in OpenFront Release Management Oct 23, 2026
@wraith4081
wraith4081 deleted the chore/oxlint-server-floating-promises branch October 26, 2026 17:14
RickD004 pushed a commit to RickD004/OpenFrontIO that referenced this pull request Oct 28, 2026
)

## Description:

Follow-up to openfrontio#6101. That one turned on `typescript/no-floating-promises`
for src/server only and left the client for later. This finishes it: the
rule now covers the whole repo, and the src/server override is gone.

Most of the 167 hits were Lit event handlers and other fire-and-forget
calls (`putGameConfig()`, the clan `loadX()` calls, `gamePortal.*`,
`updateComplete.then(...)`), plus a few `trigger("close")` calls in
server tests. Those only get `void`, so runtime behavior stays the same.
It's a big diff (51 files), but nearly every line is the same one-word
change.

I found one real bug. `HomepagePromos.close()` and
`InGamePromo.hideAd()` called `window.ramp.destroyUnits()` inside a
try/catch without awaiting it. `destroyUnits` returns a promise, so the
catch only saw sync throws. A rejection skipped the warning and became
an unhandled rejection, and the "successfully destroyed" line was logged
before the destroy had finished. Both now use
`Promise.all(...).then(log).catch(warn)`, the same pattern
`destroyBottomRailUnit` already uses in that file.

Heads-up:
- `void` is still the quickest way to make the rule go quiet. If a
failure matters to the caller, please use `await` or `.catch()` instead.
Keep `void` for calls that really are fire-and-forget.
- A failed ad destroy now logs a `console.warn` instead of an unhandled
rejection, so it might show up a little differently in telemetry.

## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [ ] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [ ] I have added relevant tests to the test directory

## Please put your Discord username so you can be contacted if a bug or
regression is found:

wraith4081

This branch was previously deployed

1 inactive deployment
backport — cb131177 Deployed Oct 23, 2026 by evanpelle via Cherry-pick #563
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants