fix(stream): upgrade `@hono/node-server` to v2 and fix abort handling (#4940)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Yusuke Wada · committed by GitHub · parent 54f2f0c · Browse files · 5 files·+13 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+13 added−15 removed
- tests:+4 added−8 removed
- other:+9 added−7 removed
Provenance
- Commit
e2f252a- Tree
a979efb- Author
Yusuke Wada <yusuke@kamawada.com>- Committer
GitHub <noreply@github.com>- Parent
54f2f0c
5 files changed+13 added−15 removed
modified:.github/workflows/ci.yml+1 added-1 removed
127 unmodified lines128 name: 'Node.js v${{ matrix.node }}'129 runs-on: ubuntu-latest130 strategy:131 matrix:132- node: ['18.18.2', '20.x', '22.x']132+ node: ['20.x', '22.x', '24.x']133 steps:134 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6135 - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6136 with:131 unmodified linesmodified:runtime-tests/node/index.test.ts+4 added-8 removed
131 unmodified lines132 })133 134 it('Should call onAbort', async () => {135 const controller = new AbortController()136- const res = expect(agent.get('/stream', { signal: controller.signal })).rejects.toThrow(137- 'This operation was aborted'138- )136+ const req = agent.get('/stream', { signal: controller.signal })137 138 expect(aborted).toBe(false)139 await new Promise((resolve) => setTimeout(resolve, 10))140 controller.abort()143- await res141+ await req.catch(() => {})142 while (!aborted) {143 await new Promise((resolve) => setTimeout(resolve))144 }145 expect(aborted).toBe(true)39 unmodified lines185 })186 187 it('Should call onAbort', async () => {188 const controller = new AbortController()191- const res = expect(agent.get('/stream', { signal: controller.signal })).rejects.toThrow(192- 'This operation was aborted'193- )189+ const req = agent.get('/stream', { signal: controller.signal })190 191 expect(aborted).toBe(false)192 await new Promise((resolve) => setTimeout(resolve, 10))193 controller.abort()198- await res194+ await req.catch(() => {})195 while (!aborted) {196 await new Promise((resolve) => setTimeout(resolve))197 }198 expect(aborted).toBe(true)99 unmodified linesmodified:src/utils/stream.ts+4 added-2 removed
36 unmodified lines37383940414142434445464718 unmodified lines66676869707172737475737677787919 unmodified lines36 unmodified lines const { done, value } = await reader.read() done ? controller.close() : controller.enqueue(value) }, cancel: () => { if (!this.closed) { this.abort() this.abort() } }, }) }
18 unmodified lines return new Promise((res) => setTimeout(res, ms)) }
async close() { this.closed = true try { await this.writer.close() } catch { // Do nothing. If you want to handle errors, create a stream by yourself. } this.closed = true }
async pipe(body: ReadableStream) { this.writer.releaseLock()19 unmodified linesmodified:bun.lock+3 added-3 removed
4 unmodified lines5 "": {6 "name": "hono",7 "devDependencies": {8 "@hono/eslint-config": "^2.1.0",9- "@hono/node-server": "^1.13.5",9+ "@hono/node-server": "^2.0.2",10 "@types/glob": "^9.0.0",11 "@types/jsdom": "^21.1.7",12 "@types/node": "^24.3.0",13 "@types/ws": "^8.18.1",164 unmodified lines178 "@fastly/js-compute": ["@fastly/js-compute@3.23.0", "", { "dependencies": { "@bytecodealliance/jco": "^1.5.0", "@bytecodealliance/weval": "^0.3.2", "@bytecodealliance/wizer": "^7.0.5", "acorn": "^8.12.1", "acorn-walk": "^8.3.3", "esbuild": "^0.23.1", "magic-string": "^0.30.11", "regexpu-core": "^6.0.0" }, "bin": { "js-compute": "js-compute-runtime-cli.js", "js-compute-runtime": "js-compute-runtime-cli.js" } }, "sha512-DZ1rLBMm2veeDF+8oiVgC54cBx/SuqUH2ov7f3K7EtbZJx5C9bSTg9fBhzD/hbJkucSfveu7oIOyqXQWP4cASw=="],179 180 "@hono/eslint-config": ["@hono/eslint-config@2.1.0", "", { "dependencies": { "@eslint/js": "^9.39.3", "eslint-config-prettier": "^10.1.8", "eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-import-x": "^4.16.1", "eslint-plugin-n": "^17.24.0", "typescript-eslint": "^8.56.1" }, "peerDependencies": { "eslint": "^9.0.0", "typescript": "^5.0.0" } }, "sha512-uNR7As09OPTFLj5f6JwMd5DgTkEhMMlN8kqSlHmPYDU0p3voyaDghNahckydnAdhxIyRHrZhtLkuJDmZ5aeiqg=="],181 182- "@hono/node-server": ["@hono/node-server@1.13.5", "", { "peerDependencies": { "hono": "^4" } }, "sha512-lSo+CFlLqAFB4fX7ePqI9nauEn64wOfJHAfc9duYFTvAG3o416pC0nTGeNjuLHchLedH+XyWda5v79CVx1PIjg=="],182+ "@hono/node-server": ["@hono/node-server@2.0.2", "", { "peerDependencies": { "hono": "^4" } }, "sha512-tXlTi1h/4V7sDe7i97IVP+9re9ZU7wXZZggnR5ucCRclf1+AX6YhGStrR5w8bLj+3Mlyl0pKfBh9gqTqqnGKfQ=="],183 184 "@humanfs/core": ["@humanfs/core@0.19.1", "", {}, "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA=="],185 186 "@humanfs/node": ["@humanfs/node@0.16.7", "", { "dependencies": { "@humanfs/core": "^0.19.1", "@humanwhocodes/retry": "^0.4.0" } }, "sha512-/zUx+yOsIrG4Y43Eh2peDeKCxlRt/gET6aHfaKpuq267qXdYDFViVHfMaLyygZOnl0kGWxFIgsBy8QFuTLUXEQ=="],691 unmodified lines878 "has-flag": ["has-flag@4.0.0", "", {}, "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="],879 880 "headers-polyfill": ["headers-polyfill@4.0.3", "", {}, "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ=="],881 882- "hono": ["hono@4.6.3", "", {}, "sha512-0LeEuBNFeSHGqZ9sNVVgZjB1V5fmhkBSB0hZrpqStSMLOWgfLy0dHOvrjbJh0H2khsjet6rbHfWTHY0kpYThKQ=="],882+ "hono": ["hono@4.12.18", "", {}, "sha512-RWzP96k/yv0PQfyXnWjs6zot20TqfpfsNXhOnev8d1InAxubW93L11/oNUc3tQqn2G0bSdAOBpX+2uDFHV7kdQ=="],883 884 "hosted-git-info": ["hosted-git-info@8.0.2", "", { "dependencies": { "lru-cache": "^10.0.1" } }, "sha512-sYKnA7eGln5ov8T8gnYlkSOxFJvywzEx9BueN6xo/GKO8PGiI6uK6xx+DIGe45T3bdVjLAQDQW1aicT8z8JwQg=="],885 886 "html-encoding-sniffer": ["html-encoding-sniffer@3.0.0", "", { "dependencies": { "whatwg-encoding": "^2.0.0" } }, "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA=="],1408 unmodified linesmodified:package.json+1 added-1 removed
655 unmodified lines656 "nodejs"657 ],658 "devDependencies": {659 "@hono/eslint-config": "^2.1.0",660- "@hono/node-server": "^1.13.5",660+ "@hono/node-server": "^2.0.2",661 "@types/glob": "^9.0.0",662 "@types/jsdom": "^21.1.7",663 "@types/node": "^24.3.0",664 "@types/ws": "^8.18.1",28 unmodified lines