Skip to content

πŸ› Bug Report β€” nodeTimersPromises.setImmediate is read-onlyΒ #5844

@vicb

Description

@vicb

Ref: Open Next issue

Next 16.1 has the following code:

let nodeTimersPromises=require("node:timers/promises");
nodeTimersPromises.setImmediate=patchedSetImmediatePromise;

It crashes workerd with:

[wrangler:error] TypeError: Cannot assign to read only property 'setImmediate' of object '[object Module]'
    at install (file:///Users/vberchet/code/work/opennextjs-cloudflare/examples/e2e/app-router/.open-next/server-functions/default/examples/e2e/app-router/handler.mjs:8:21434)

However both the snippets work with Node:

// cjs
nodeTimersPromises=require("node:timers/promises");
nodeTimersPromises.setImmediate=()=>console.log('test');
nodeTimersPromises.setImmediate()

// esm
import ntp from 'node:timers/promises';
ntp.setImmediate = ()=>console.log('test');
ntp.setImmediate();

I have tried to use the following compat flags but if didn't help:

  • disable_fast_jsg_struct
  • mutable_api_prototypes

I wasn't able to test with enable_nodejs_global_timers but we should make sure the fix works whether or not this flag is set.

/cc @danlapid @jasnell @southpolesteve

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions