Description
What happened?
I attempted to use @octokit/webhooks
in a Cloudflare Worker. When processing GitHub webhook events, the worker throws a TypeError: setTimeout(...).unref is not a function
. This occurs because, quoting from Cloudflare Workers Timers Docs:
When called from a global level (on globalThis), functions such as
clearTimeout
andsetTimeout
will respect web standards rather than Node.js-specific functionality. For complete Node.js compatibility, you must call functions from thenode:timers
module.
webhooks.js/src/middleware/web/middleware.ts
Lines 83 to 91 in 6dd5d30
Expected Behavior: The library should work in Cloudflare Workers without errors. Since unref()
is not available in browser-like environments or CF Workers, the code should check for its existence before calling it or avoid using unref()
in web-targeted builds.
Versions
@octokit/[email protected]
[email protected]
# wrangler.toml
compatibility_date = "2025-04-27"
compatibility_flags = ["nodejs_compat"]
Relevant log output
2025-04-27 12:51:29.308 ERROR /home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
TypeError setTimeout(...).unref is not a function
error stack:
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:148
•
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:147
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:1
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:1
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
• index.js
/home/liblaf/github/liblaf/liblaf-bot/.wrangler/tmp/dev-pYYrLd/index.js:170
Code of Conduct
- I agree to follow this project's Code of Conduct
Sub-issues
Metadata
Metadata
Assignees
Type
Projects
Status