Skip to content

Commit fbd4581

Browse files
committed
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 eventsource v3+ no longer provides a default export. Fixes: #706 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
1 parent 2723715 commit fbd4581

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎server.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ app.listen(port, () => {
2222
// may open up an SSE relay channel helpful for local debugging
2323
// of github repository events, wo/having to deploy changes
2424
if (process.env.SSE_RELAY) {
25-
const EventSource = require('eventsource')
25+
const { EventSource } = await import('eventsource')
2626
const es = new EventSource(process.env.SSE_RELAY)
2727
es.onmessage = (e) => {
2828
try {

0 commit comments

Comments
 (0)