MCPcopy
hub / github.com/visgl/deck.gl / cleanupAfterLayerTestsAsync

Function cleanupAfterLayerTestsAsync

modules/test-utils/src/lifecycle-test.ts:335–352  ·  view source on GitHub ↗

* Async cleanup that waits for pending async operations before finalizing resources. * This prevents unhandled rejections from luma.gl's async shader error reporting * which may try to access destroyed WebGL resources if cleanup happens too early.

({
  layerManager,
  deckRenderer,
  oldResourceCounts
}: TestResources)

Source from the content-addressed store, hash-verified

333 * which may try to access destroyed WebGL resources if cleanup happens too early.
334 */
335async function cleanupAfterLayerTestsAsync({
336 layerManager,
337 deckRenderer,
338 oldResourceCounts
339}: TestResources): Promise<Error | null> {
340 layerManager.setLayers([]);
341
342 // Wait for any pending async operations (e.g., luma.gl's deferred shader compilation
343 // error handling) to complete before destroying resources. This prevents
344 // "getProgramInfoLog" errors when async error reporting tries to access
345 // already-destroyed WebGL programs.
346 await new Promise(resolve => setTimeout(resolve, 0));
347
348 layerManager.finalize();
349 deckRenderer.finalize();
350
351 return getResourceCountDelta(oldResourceCounts);
352}
353
354function getResourceCounts(): Record<string, number> {
355 /* global luma */

Callers 1

testLayerAsyncFunction · 0.85

Calls 3

getResourceCountDeltaFunction · 0.85
setLayersMethod · 0.80
finalizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…