Skip to content

fix: destroy non-200 responses so their sockets close - #42

Merged
joker23 merged 1 commit into
launchdarkly:mainfrom
dany74q:danny/destroy-unread-response
Sep 28, 2026
Merged

joker23 merged 1 commit into
launchdarkly:mainfrom
dany74q:danny/destroy-unread-response

Conversation

@dany74q

@dany74q dany74q commented Sep 28, 2026 •

Copy link
Copy Markdown

Note

Overview
Fixes a connection leak when the server returns redirects or non-200 HTTP responses: the client now calls res.destroy() on those responses before following redirects or surfacing errors, so the underlying socket is torn down instead of staying open (notably when using a keep-alive http.Agent).

Tests add a keep-alive agent helper and assert the server socket closes for 301/307 redirects and for error statuses 301, 307, 401, and 503.

Reviewed by Cursor Bugbot for commit c0ba67c. Bugbot is set up for automated code reviews on this repo. Configure here.

@joker23

joker23 commented Sep 28, 2026

Copy link
Copy Markdown

Hey @dany74q - thanks for the report and the contrib! Your changes look good to me and I will kick off the rest of the CI to make sure things are passing.

NOTE: I am in the process of migrating this package into https://github.com/launchdarkly/js-core, no real timeline at the moment so just an FYI for now.

@joker23
joker23 merged commit 988a7b3 into launchdarkly:main Sep 28, 2026
5 checks passed
tanderson-ld added a commit that referenced this pull request Sep 29, 2026
…ions (#43)

## What

Adds an explicit `permissions:` block (`contents: write`,
`pull-requests: write`) to the `release-please` job in
`.github/workflows/release-please.yml`.

## Why

release-please has failed on every push to `main` since 2026-09-23 (the
runs for #38, #40, #42), all with the same error:

```
POST /repos/launchdarkly/js-eventsource/git/refs
→ 403 "Resource not accessible by integration"   (x-accepted-github-permissions: contents=write)
✖ Error when creating branch
release-please failed: Error creating Pull Request: Resource not accessible by integration
```

The `release-please` job passes `token: ${{secrets.GITHUB_TOKEN}}` but
had **no `permissions:` block**, so it inherited the repository's
*default* `GITHUB_TOKEN` permissions. It worked for every release
through 2.2.0 (Apr 2025) because that default was read-write; it broke
once the default was tightened to read-only, which removed the write
access the job needs to create the release branch/PR. The workflow file
itself has not changed since 2024-04-26 — only the environment did.

(The lone "success" on 2026-09-23 was a `chore:` push, which
release-please treats as non-release-worthy, so it never reached the
branch-creation step. The next release-worthy commits — #38, #40, #42 —
all hit the 403.)

## Fix

Grant the two write scopes explicitly on the job that needs them, so the
workflow no longer depends on the repo default. This brings the job to
parity with the js-core monorepo's `release-please` job, which already
sets `contents: write` + `pull-requests: write` explicitly and continues
to run successfully under the same `GITHUB_TOKEN`.

## Effect

Once merged, the push to `main` re-runs release-please with the
corrected permissions and it will open the pending release PR (covering
the currently-unreleased #38, #40, #42), which on merge publishes the
next version.

## Notes / possible follow-ups (intentionally not in this PR)

- If the org has *also* disabled "Allow GitHub Actions to create and
approve pull requests," a later run could 403 on the PR-create step (a
separate setting from token scope). That setting was clearly enabled
through the 2.2.0 release, so it is likely still fine.
- The action reference here
(`google-github-actions/release-please-action@v4`) is the old org name
on a floating tag; js-core uses the renamed
`googleapis/release-please-action` pinned to a SHA. Modernizing it is
optional and left out to keep this fix focused.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Fixes release-please 403 failures** by giving the `release-please`
job explicit `GITHUB_TOKEN` scopes instead of relying on the repo
default (which was tightened to read-only).
> 
> The job now declares `contents: write` and `pull-requests: write` so
it can create the release branch/tag and open or update the release PR.
The downstream `release-package` job already had these permissions; only
`release-please` was missing them, which caused `Resource not accessible
by integration` on recent pushes to `main`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
97f01e5. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
tanderson-ld pushed a commit that referenced this pull request Sep 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.3.0](2.2.0...2.3.0)
(2026-09-29)


### Features

* allow a custom retry delay strategy to be provided
([#40](#40))
([dd081f0](dd081f0))


### Bug Fixes

* anchor retry backoff reset to the first event of each connection
([#38](#38))
([9d46860](9d46860))
* destroy non-200 responses so their sockets close
([c0ba67c](c0ba67c))
* destroy non-200 responses so their sockets close
([#42](#42))
([988a7b3](988a7b3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> This PR **bumps the package to 2.3.0** via Release Please:
`package.json`, `.release-please-manifest.json`, and a new **2.3.0**
section in `CHANGELOG.md`.
> 
> There are **no runtime or library code changes** in the diff itself.
The changelog records what ships in this tag: **custom
`retryDelayStrategy`** for reconnect timing, **retry backoff reset tied
to the first event on each connection**, and **destroying non-200 HTTP
responses** so underlying sockets close cleanly.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ebf94e0. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants