Skip to content

Commit a4a6a8e

Browse files
committed
feat: add header overflow detection and user guidance for large HTTP headers
1 parent aee25ed commit a4a6a8e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- Fix errors when the target is using a CDN
1515
- Fix "possible EventEmitter memory leak detected" error
1616
- Fix "Maximum call stack size exceeded" error in resolveNodeValue
17+
- Fix "UND_ERR_HEADERS_OVERFLOW" error
1718

1819
## 1.2.1-alpha.2 - 2025.08.06
1920

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ USER pptruser
1616
RUN npx puppeteer browsers install chrome
1717

1818
ENV IS_DOCKER=true
19+
ENV NODE_OPTIONS="--max-http-header-size=99999999"
1920
ENTRYPOINT ["node", "build/index.js"]

src/utility/makeReq.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,19 @@ const makeRequest = async (url: string, args: RequestInit) => {
201201
}
202202
} catch (err) {
203203
counter++;
204+
// BUG: https://github.com/nodejs/node/issues/47246
205+
// if the header content is too large, it will throw an error like
206+
// code: `UND_ERR_HEADERS_OVERFLOW`
207+
// so, if this error happens, tell the user to fix it using setting the environment variables
208+
// if this is docker, this will be increased by default
209+
if (err.cause && err.cause.code === "UND_ERR_HEADERS_OVERFLOW") {
210+
console.log(
211+
chalk.yellow(
212+
`[!] The tool detected a header overflow. Please increase the limit by setting environment variable \`NODE_OPTIONS="--max-http-header-size=99999999"\`. If the error still persists, please try again with a higher limit.`
213+
)
214+
);
215+
process.exit(21);
216+
}
204217
if (counter > 10) {
205218
console.log(chalk.red(`[!] Failed to fetch ${url} : ${err}`));
206219
return null;

0 commit comments

Comments
 (0)