MCPcopy Index your code
hub / github.com/react/react / poll

Function poll

packages/react-devtools-shared/src/inspectedElementCache.js:250–282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

248 }
249
250 function poll(): Promise<void> {
251 status = 'running';
252
253 return Promise.allSettled([
254 checkForUpdate({bridge, element, refresh, store}),
255 createPromiseWhichResolvesInOneSecond(),
256 ])
257 .then(([{status: updateStatus, reason}]) => {
258 // There isn't much to do about errors in this case,
259 // but we should at least log them, so they aren't silent.
260 // Log only if polling is still active, we can't handle the case when
261 // request was sent, and then bridge was remounted (for example, when user did navigate to a new page),
262 // but at least we can mark that polling was aborted
263 if (updateStatus === 'rejected' && status !== 'aborted') {
264 // This is expected Promise rejection, no need to log it
265 if (reason instanceof ElementPollingCancellationError) {
266 return;
267 }
268
269 console.error(reason);
270 }
271 })
272 .finally(() => {
273 const shouldContinuePolling =
274 status !== 'aborted' && status !== 'paused';
275
276 status = 'idle';
277
278 if (shouldContinuePolling) {
279 return poll();
280 }
281 });
282 }
283
284 poll();
285

Callers 2

resumeFunction · 0.70

Calls 4

checkForUpdateFunction · 0.85
thenMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected