Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

"eager" instamine mode does not work in browser #3308

Closed
MicaiahReid opened this issue Jun 28, 2022 · 2 comments
Closed

"eager" instamine mode does not work in browser #3308

MicaiahReid opened this issue Jun 28, 2022 · 2 comments

Comments

@MicaiahReid
Copy link
Contributor

When using Ganache in the browser, the following line fails:

if (options.miner.instamine === "eager") {
  // in eager instamine mode we must delay the broadcast of new blocks
  await new Promise(resolve => {
    // we delay emitting blocks and blockLogs because we need to allow for:
    // ```
    //  await provider.request({"method": "eth_sendTransaction"...)
    //  await provider.once("message") // <- should work
    // ```
    // If we don't have this delay here the messages will be sent before
    // the call has a chance to listen to the event.
    setImmediate(async () => {
      // emit block logs first so filters can pick them up before
      // block listeners are notified
      await Promise.all([
        this.emit("blockLogs", blockLogs),
        this.emit("block", block)
      ]);
      resolve(void 0);
    });
  });
}

With the error: setImmediate is not defined.

It looks like setImmediate needs to be polyfilled for "eager" mode to work properly in the browser.

@davidmurdoch
Copy link
Member

// polyfill "setImmediate" for the browser
🤔

@MicaiahReid
Copy link
Contributor Author

Ooops, I was testing against the wrong branch! This was fixed in #3130

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants