Skip to content

Commit

Permalink
fix: access process from globalThis (#14)
Browse files Browse the repository at this point in the history
Fixes webpack error:

```
Module not found: Error: Can't resolve 'process/browser' in /path/...
```

Falls back to `setImmediate`, then `setTimeout`.
  • Loading branch information
achingbrain authored Sep 29, 2021
1 parent 6e54ba3 commit 7874fd7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class BlockstoreDatastoreAdapter extends BaseBlockstore {

// process.nextTick runs on the microtask queue, setImmediate runs on the next
// event loop iteration so is slower. Use process.nextTick if it is available.
const runner = process && process.nextTick ? process.nextTick : setImmediate
const runner = globalThis.process && globalThis.process.nextTick ? globalThis.process.nextTick : (globalThis.setImmediate || globalThis.setTimeout)

runner(async () => {
try {
Expand Down

0 comments on commit 7874fd7

Please sign in to comment.