Skip to content

fix: Prevent stale keep-alive sockets from failing create-vsix - #868

Merged
TwitchBronBron merged 1 commit into
masterfrom
fix-create-vsix-fetch-socket
Aug 3, 2026
Merged

fix: Prevent stale keep-alive sockets from failing create-vsix#868
TwitchBronBron merged 1 commit into
masterfrom
fix-create-vsix-fetch-socket

Conversation

@TwitchBronBron

Copy link
Copy Markdown
Member

create-vsix has been failing on most runs since #867, with:

TypeError: fetch failed
    at async findOpenPr (scripts/create-vsix.ts:141:22)
  [cause]: SocketError: other side closed
    code: 'UND_ERR_SOCKET',

Cause

findOpenPr runs once per project, and consecutive calls are separated by multi-minute npm i && npm run build && npm pack runs. GitHub closes idle keep-alive sockets long before the next call, but undici still takes the dead socket from its connection pool, so the request fails before it ever leaves the machine.

The socket dump confirms it — bytesWritten/bytesRead are non-zero, so the connection had already completed one request/response cycle before being reused.

Because main() is async with .catch(… process.exit(1)), a single failed lookup aborts the entire build after several projects have already been built.

Fix

Send connection: close on the lookup requests so each gets a fresh socket.

Verification

Ran the full script locally exactly as CI does:

Also ruled out the other candidate explanations:

  • Not auth — reproduced locally with no GITHUB_TOKEN set, so no authorization header was sent at all. Auth failures would also return HTTP 401/403 and hit the existing !response.ok branch rather than throwing.
  • Not a malformed URL — the first two lookups succeed using identical URL-construction code, and hitting the exact encoded URL directly returns HTTP 200.
  • Not general network flakiness — reproduced on the first attempt on a different machine, network, GitHub IP, and Node/undici version.

Note

This removes the cause, but a transient network blip could still abort a build, since the throw bypasses the graceful !response.ok handling immediately below it. These lookups only improve ref resolution — priorities 3 and 4 (git ls-remote, then master) still produce a valid vsix. Wrapping the fetch in a try/catch that returns undefined would make failures degrade instead of abort. Left out here to keep the fix focused; happy to add it if wanted.

🤖 Generated with Claude Code

findOpenPr was intermittently dying with 'TypeError: fetch failed' /
UND_ERR_SOCKET 'other side closed', aborting the whole build.

The lookups happen once per project, separated by multi-minute
npm install/build/pack runs. GitHub closes idle keep-alive sockets well
before the next call, but undici still pulls the dead socket from its
pool and the request fails before leaving the machine.

Send 'connection: close' so each lookup gets a fresh socket.

Reproduced locally (failed at roku-debug) and confirmed fixed: all five
projects now resolve, including the PR lookup that finds #855.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@TwitchBronBron TwitchBronBron added the create-vsix PRs with this tag will trigger a vsix build on vscode-brightscript-language for every push label Jul 31, 2026
@rokucommunity-bot

Copy link
Copy Markdown
Contributor

Hey there! I just built a new version of the vscode extension based on 5c4158c.

📦 Download the .vsix

See the install instructions if you need them. This replaces your marketplace version of the extension until you reinstall it.

Built from:

  • roku-deploy: rokucommunity branch 'master'
  • brighterscript: rokucommunity branch 'master'
  • roku-debug: rokucommunity branch 'master'
  • brighterscript-formatter: rokucommunity branch 'master'
  • vscode-brightscript-language: rokucommunity branch 'fix-create-vsix-fetch-socket' (open PR fix: Prevent stale keep-alive sockets from failing create-vsix #868)

Prefer to keep the marketplace version installed? There's also a side-by-side build that installs as a separate extension. Be sure to disable the marketplace version while testing it, otherwise the two will conflict.

@TwitchBronBron
TwitchBronBron merged commit 2642ba0 into master Aug 3, 2026
8 of 9 checks passed
@TwitchBronBron
TwitchBronBron deleted the fix-create-vsix-fetch-socket branch August 3, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

create-vsix PRs with this tag will trigger a vsix build on vscode-brightscript-language for every push

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant