From 02c6e32291f3c1a8071b7c88aa1fd9696d5a21ba Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Sat, 24 Oct 2026 12:26:20 +0530 Subject: [PATCH] fix: load eventsource with import() for the SSE relay server.js became an ES module in the ESM migration, but the SSE_RELAY code path still used require('eventsource'). Setting SSE_RELAY, as the README recommends for local development, made the bot fail to start with ERR_AMBIGUOUS_MODULE_SYNTAX (require() is not available in ESM). Load it with a dynamic import() instead, which keeps eventsource an optional dev-only dependency, and use its named EventSource export since the eventsource version in use (v5) has no default export. Fixes: https://github.com/nodejs/github-bot/issues/706 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com> --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.js b/server.js index 71b3961b..d39c2c17 100644 --- a/server.js +++ b/server.js @@ -22,7 +22,7 @@ app.listen(port, () => { // may open up an SSE relay channel helpful for local debugging // of github repository events, wo/having to deploy changes if (process.env.SSE_RELAY) { - const EventSource = require('eventsource') + const { EventSource } = await import('eventsource') const es = new EventSource(process.env.SSE_RELAY) es.onmessage = (e) => { try {