Skip to content

fix(gateway): prevent crashes when encoding images on windows - #1016

Merged
nixuuu merged 3 commits into
devfrom
canopy/zdiagnozuj-i-w-50rc
Nov 19, 2026
Merged

nixuuu merged 3 commits into
devfrom
canopy/zdiagnozuj-i-w-50rc

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Create, lock and read the bounded encoder output through a single Win32 handle. Passing a Bun file descriptor to the separate CRT used by _get_osfhandle could terminate the gateway process.
  • Keep the OS-enforced byte limit, check the encoded size before allocating, and close the handle on success or failure.
  • Add Windows smoke coverage for an ordinary PNG and an encode that exceeds its output budget. The smoke exercises the checkout encoder and Sharp with Bun from the signed desktop installation.

Fixes: #651

Incident

The reported local gateway at 0.3.0-nightly.75 repeatedly exited with Windows status 0xc0000409 and had no liveness failures leading up to the exits. On the affected builds, a pending image publication could replay after reconnect and wait for its 60-second database lease. The encoder crash reproduces on Windows with the same native status. The reporter's log leaves the trigger for each exit undetermined.

Verification

  • The original encoder terminated the installed Bun with 0xc0000409 during the new Windows regression. Windows run before the fix
  • Signed Windows install and both encoder regressions passed on PR head 89027e38. Windows run with the fix
  • On nix-pc at 89027e38, 26 focused tests passed through check:tmp and 3 Windows-only cases were skipped. Gateway typecheck, scoped lint and the diff check passed. An isolated real sidecar on the same gateway implementation answered 27 probes and authenticated RPCs over 130 seconds before recovering from a forced exit.
  • GitHub PR checks are pending. The reporter's Windows 11 installation has yet to run the fix.

@nixuuu
nixuuu marked this pull request as ready for review November 19, 2026 08:35
@nixuuu
nixuuu enabled auto-merge (squash) November 19, 2026 08:35
@nixuuu
nixuuu merged commit fe646e8 into dev Nov 19, 2026
19 checks passed
@nixuuu
nixuuu deleted the canopy/zdiagnozuj-i-w-50rc branch November 19, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant