Skip to content

Fix typos - #895

Merged
ShogunPanda merged 1 commit into
nodejs:mainfrom
DimitriPapadopoulos:typos
Nov 23, 2026
Merged

ShogunPanda merged 1 commit into
nodejs:mainfrom
DimitriPapadopoulos:typos

Conversation

@DimitriPapadopoulos

Copy link
Copy Markdown
Contributor

Fix typos found by typos.

@ShogunPanda

Copy link
Copy Markdown
Contributor

Thanks for the typo fixes in comments and benchmarks, those are fine.

The TIMEOUT_OCCURRED: 524 addition breaks the build, though: HTTP_STATUS_MAP now has two XX(524, ...) entries, so the switch in llhttp_status_name (src/native/api.c) fails to compile with duplicate case value: 'HTTP_STATUS_TIMEOUT_OCCURED' and 'HTTP_STATUS_TIMEOUT_OCCURRED' both equal '524'. npm test doesn't catch it because it doesn't compile api.c, but make build/libllhttp.a does.

TIMEOUT_OCCURED is already part of the public API/ABI, so please drop that change from this PR (or, if you want an alias, keep it out of the map used by the switch).

@DimitriPapadopoulos

Copy link
Copy Markdown
Contributor Author

I don't know much about TypeScript, my intent was to add an alias to the generated llhttp.h file.

I think it's OK to modify enum llhttp_status to contain two enums with the same value in C. However, this would require to modify the generation of HTTP_STATUS_MAP in bin/generate.ts to skip the second identical value and avoid an error in the code below — probably too involved to fix a typo:

llhttp/src/native/api.c

Lines 227 to 234 in 85c5d42

const char* llhttp_status_name(llhttp_status_t status) {
#define HTTP_STATUS_GEN(NUM, NAME, STRING) case HTTP_STATUS_##NAME: return #STRING;
switch (status) {
HTTP_STATUS_MAP(HTTP_STATUS_GEN)
default: abort();
}
#undef HTTP_STATUS_GEN
}

As suggested, I can keep HTTP_STATUS_TIMEOUT_OCCURED/524 as part of the API and create an HTTP_STATUS_TIMEOUT_OCCURRED constant alias instead. Instead, I could change the enum to HTTP_STATUS_TIMEOUT_OCCURRED/524 and have HTTP_STATUS_TIMEOUT_OCCURED be the constant alias, but I suspect this would break the TypeScript API, wouldn't it?

@ShogunPanda

Copy link
Copy Markdown
Contributor

Thanks! Yes, renaming the enum and making TIMEOUT_OCCURED the alias would change the TypeScript STATUSES keys and the string returned by llhttp_status_name, so that's a breaking change we'd rather avoid for an unofficial status code.

Let's keep this PR to the plain typo fixes: please drop the TIMEOUT_OCCURRED line from src/llhttp/constants.ts and we can land it right away. If you still want the alias, a separate PR adding #define HTTP_STATUS_TIMEOUT_OCCURRED HTTP_STATUS_TIMEOUT_OCCURED (outside the generated HTTP_STATUS_MAP) would be welcome.

@DimitriPapadopoulos

Copy link
Copy Markdown
Contributor Author

I tried to modify bin/generate.ts to skip the second key with an identical value, but I can defer this proposal to a different PR.

Signed-off-by: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com>
@DimitriPapadopoulos

Copy link
Copy Markdown
Contributor Author

Fixed to include only simple typo fixes, and rebased.

@ShogunPanda
ShogunPanda merged commit 1bd82f3 into nodejs:main Nov 23, 2026
7 checks passed
@DimitriPapadopoulos
DimitriPapadopoulos deleted the typos branch November 23, 2026 08:28
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