diff --git a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js index 4cba5aa91405b..d08aafbcf2a19 100644 --- a/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js +++ b/packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMEdge-test.js @@ -15,6 +15,10 @@ global.ReadableStream = global.TextEncoder = require('util').TextEncoder; global.TextDecoder = require('util').TextDecoder; +// Don't wait before processing work on the server. +// TODO: we can replace this with FlightServer.act(). +global.setTimeout = cb => cb(); + let clientExports; let webpackMap; let webpackModules; diff --git a/packages/react-server/src/ReactServerStreamConfigEdge.js b/packages/react-server/src/ReactServerStreamConfigEdge.js index a898e6b8d40fe..d4157623e452d 100644 --- a/packages/react-server/src/ReactServerStreamConfigEdge.js +++ b/packages/react-server/src/ReactServerStreamConfigEdge.js @@ -13,7 +13,7 @@ export type PrecomputedChunk = Uint8Array; export opaque type Chunk = Uint8Array; export function scheduleWork(callback: () => void) { - callback(); + setTimeout(callback, 0); } export function flushBuffered(destination: Destination) { diff --git a/packages/react/src/__tests__/ReactFetchEdge-test.js b/packages/react/src/__tests__/ReactFetchEdge-test.js index 10484b853bf50..832b8e542843e 100644 --- a/packages/react/src/__tests__/ReactFetchEdge-test.js +++ b/packages/react/src/__tests__/ReactFetchEdge-test.js @@ -20,6 +20,10 @@ global.Response = require('node-fetch').Response; // Patch for Edge environments for global scope global.AsyncLocalStorage = require('async_hooks').AsyncLocalStorage; +// Don't wait before processing work on the server. +// TODO: we can replace this with FlightServer.act(). +global.setTimeout = cb => cb(); + let fetchCount = 0; async function fetchMock(resource, options) { fetchCount++;