-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: bump hono to v3.12.8, add customer err tests for compress middl… #130
feat: bump hono to v3.12.8, add customer err tests for compress middl… #130
Conversation
@ariskemper |
Thank you for your patience. I have confirmed that the error is resolved in 3.12.8. I think it is a bug in node-server that the content-type does not have UTF-8. diff --git a/package.json b/package.json
index 732dd32..c20eb7e 100644
--- a/package.json
+++ b/package.json
@@ -68,7 +68,7 @@
"@types/supertest": "^2.0.12",
"@whatwg-node/fetch": "^0.9.14",
"eslint": "^8.55.0",
- "hono": "3.12.7",
+ "hono": "^3.12.8",
"jest": "^29.6.1",
"np": "^7.7.0",
"publint": "^0.1.16",
diff --git a/src/listener.ts b/src/listener.ts
index 1e02c5c..e8da26c 100644
--- a/src/listener.ts
+++ b/src/listener.ts
@@ -25,7 +25,7 @@ const handleResponseError = (e: unknown, outgoing: ServerResponse | Http2ServerR
console.info('The user aborted a request.')
} else {
console.error(e)
- if (!outgoing.headersSent) outgoing.writeHead(500, { 'Content-Type': 'text/plain' })
+ if (!outgoing.headersSent) outgoing.writeHead(500, { 'Content-Type': 'text/plain;charset=UTF-8' })
outgoing.end(`Error: ${err.message}`)
outgoing.destroy(err)
}
diff --git a/test/server.test.ts b/test/server.test.ts
index 66e6b99..58a5899 100644
--- a/test/server.test.ts
+++ b/test/server.test.ts
@@ -73,8 +73,7 @@ describe('Basic', () => {
expect(res.headers['content-type']).toEqual('text/plain;charset=UTF-8')
})
- // it fails with hono 3.12.7
- it.skip('Should return 200 response - GET /ponyfill', async () => {
+ it('Should return 200 response - GET /ponyfill', async () => {
const res = await request(server).get('/ponyfill')
expect(res.status).toBe(200)
expect(res.headers['content-type']).toMatch(/text\/plain/)
diff --git a/yarn.lock b/yarn.lock
index e201646..2b35c64 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2924,10 +2924,10 @@ hexoid@^1.0.0:
resolved "https://registry.yarnpkg.com/hexoid/-/hexoid-1.0.0.tgz#ad10c6573fb907de23d9ec63a711267d9dc9bc18"
integrity sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==
-hono@3.12.7:
- version "3.12.7"
- resolved "https://registry.yarnpkg.com/hono/-/hono-3.12.7.tgz#76be7d8a2f43ef29bba47e663b1adfba264a3281"
- integrity sha512-jfyIoE8D5I1PGj0tXAGqpQ2miAWBBuHFjJsWjh0hbBVludQ8QO4lF6KTbPvjMi4venp8Q6DyMoJ51CwP6L5LNA==
+hono@^3.12.8:
+ version "3.12.8"
+ resolved "https://registry.yarnpkg.com/hono/-/hono-3.12.8.tgz#7c137aa6ac7bcd2aec3f55b9596d71e97081963a"
+ integrity sha512-vnOEIRdqsp4uHE/dkOBr9EYmTsR86sD/FyG2xhfAQzR9udDRglN1nuO7SGc/7U3HfSorc6PSCNGN6upnVtCmfg==
hosted-git-info@^2.1.4:
version "2.8.9" |
@ariskemper Please remove the Is there any reason why it should be |
60e9547
to
6b63231
Compare
@ariskemper Thank you! LGTM! |
@yusukebe could you create a new release including this PR? |
Okay! But please run |
@ariskemper
|
@usualoma i have seen, that if, else was used in many places and many times could be written differently or simplified, but this change was more objective changing if, else to use ternary operator to write it in a more concise way. Some devs prefer to use if, else over ternary operator. |
@ariskemper In any case, I don't think changing the style of if statements is something to be mixed into PR as a refactoring, since it is largely a matter of preference. If you think such a rewrite in general would be useful, please create a separate PR for it and convince us by writing a rationale why you think it would be useful. |
Ternary is useful, but surely we should also specify in Linter whether ternary should be used or not. https://eslint.org/docs/latest/rules/no-ternary We can do this in ESLint with the |
@usualoma @yusukebe it actually shortens the code and remove identation, that's why i prefer it over single line block if, else statements. |
ternaryThe ternary itself I don't dislike; I prefer to use it when returning. return condition ? a : b However, I think it is bad style to assign within ternary. k === 'set-cookie' ? cookies.push(v) : (res[k] = v) But sorry, about 0885eab, I don't think it's right to mix it in a PR that says "feat: bump hono to v3.12.8, add customer err tests for compress middl..." |
@usualoma could you explain more in detail, why do you think it should be used just when it is returning a value or storing it in a variable and why do you think using it this way is bad style? I agree that i should put it in a separate PR. |
@ariskemper I think ternary should be used as an "expression (returning a value)". I don't think it should be used as a "statement" for side effects. This is fine, since ternary is used as an "expression", condition ? a : b This is bad because it is a ternary used as a "statement". k === 'set-cookie' ? cookies.push(v) : (res[k] = v) But still, I don't think it is good that this discussion is taking place in a PR that says "feat: bump hono to v3.12.8, add customer err tests for compress middl..." |
Once the rules are set, I will follow them, but for my taste, I find this example to be fine. As for ternary, I think it is good when used as an "expression" and bad when used as a "statement" with the main purpose of side effects. Personally, however, I think that in many cases it is "fine to write it either way" and it is often better not to dare to subject it to refactoring. |
This PR did an excellent job and led to fixing bugs in hono itself. Thanks to @ariskemper for creating it. I think 0885eab should be revert and merged as I think it does more than the job this PR should do. I think it is better to discuss elsewhere whether 0885eab is needed or not. |
This reverts commit 0885eab.
Thanks both. Merging now. |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@hono/node-server](https://github.com/honojs/node-server) | [`1.7.0` -> `1.8.2`](https://renovatebot.com/diffs/npm/@hono%2fnode-server/1.7.0/1.8.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>honojs/node-server (@​hono/node-server)</summary> ### [`v1.8.2`](https://github.com/honojs/node-server/releases/tag/v1.8.2) [Compare Source](https://github.com/honojs/node-server/compare/v1.8.1...v1.8.2) #### What's Changed - fix: duplex only has a getter by [@​wenerme](https://github.com/wenerme) in [https://github.com/honojs/node-server/pull/149](https://github.com/honojs/node-server/pull/149) #### New Contributors - [@​wenerme](https://github.com/wenerme) made their first contribution in [https://github.com/honojs/node-server/pull/149](https://github.com/honojs/node-server/pull/149) **Full Changelog**: honojs/node-server@v1.8.1...v1.8.2 ### [`v1.8.1`](https://github.com/honojs/node-server/releases/tag/v1.8.1) [Compare Source](https://github.com/honojs/node-server/compare/v1.8.0...v1.8.1) This release includes a `feat` change, but it's minor, so release this as a patch-release. #### What's Changed - feat: support keepalive property for Request object by [@​usualoma](https://github.com/usualoma) in [https://github.com/honojs/node-server/pull/148](https://github.com/honojs/node-server/pull/148) **Full Changelog**: honojs/node-server@v1.8.0...v1.8.1 ### [`v1.8.0`](https://github.com/honojs/node-server/releases/tag/v1.8.0) [Compare Source](https://github.com/honojs/node-server/compare/v1.7.0...v1.8.0) #### What's Changed - feat: bump hono to v3.12.8, add customer err tests for compress middl… by [@​ariskemper](https://github.com/ariskemper) in [https://github.com/honojs/node-server/pull/130](https://github.com/honojs/node-server/pull/130) - refactor(test): replace features to be removed in v4 by [@​ryuapp](https://github.com/ryuapp) in [https://github.com/honojs/node-server/pull/136](https://github.com/honojs/node-server/pull/136) - Catch when nodejs request is aborted by [@​M4RC3L05](https://github.com/M4RC3L05) in [https://github.com/honojs/node-server/pull/141](https://github.com/honojs/node-server/pull/141) - chore: bump hono to v4 by [@​yusukebe](https://github.com/yusukebe) in [https://github.com/honojs/node-server/pull/143](https://github.com/honojs/node-server/pull/143) - feat: use internal body if available for returning the response in its original form as much as possible by [@​usualoma](https://github.com/usualoma) in [https://github.com/honojs/node-server/pull/145](https://github.com/honojs/node-server/pull/145) #### New Contributors - [@​ariskemper](https://github.com/ariskemper) made their first contribution in [https://github.com/honojs/node-server/pull/130](https://github.com/honojs/node-server/pull/130) - [@​ryuapp](https://github.com/ryuapp) made their first contribution in [https://github.com/honojs/node-server/pull/136](https://github.com/honojs/node-server/pull/136) - [@​M4RC3L05](https://github.com/M4RC3L05) made their first contribution in [https://github.com/honojs/node-server/pull/141](https://github.com/honojs/node-server/pull/141) **Full Changelog**: honojs/node-server@v1.7.0...v1.8.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone America/Chicago, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/autoblocksai/cli). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
No description provided.