Interactive static assets stop loading after the browser stops the idle service worker, which keeps them only in memory
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- backend
Línea de trabajo
Start with packages/runtime-internal/src/interactive/worker.js and bootstrap.js to trace how static assets are registered and fetched; then read the named worker test and its Cache Storage test globals. Implement persistent asset storage across worker restarts, and verify the unit test plus the CDP end-to-end test in testing/src/specs/instrument-completion.spec.ts pass, including after a stopped worker is restarted.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
An interactive instrument's static assets stop loading once the browser stops its idle service worker. worker.js keeps the assets only in a module-level Map. Browsers terminate a service worker that has handled no event for about 30 seconds (Chrome and Firefox both use a 30 s idle timeout), even while a page it controls is open, and the next fetch starts a fresh copy of the script with an empty map. bootstrap.js posts the assets only once, before render. So any asset first requested after a pause of more than 30 s with no network activity misses the map and goes to the network, where it does not exist. Typical cases are a stimulus image shown after an instruction screen, or a sound played on a later trial. The participant sees a broken image or hears nothing, partway through a task whose data is then recorded as if the stimulus had been shown.
Where
packages/runtime-internal/src/interactive/worker.js:5-6 and 53-77:
/** @type {Map<string, string>} */
const staticAssets = new Map();
// ...
addEventListener('message', (event) => {
// ...
Object.entries(data.staticAssets).forEach(([key, value]) => {
staticAssets.set(key, value);
});
event.ports[0]?.postMessage({ type: 'STATIC_ASSETS_READY' });
});
worker.addEventListener('fetch', (_event) => {
// ...
if (staticAssets.has(pathname)) {
packages/runtime-internal/src/interactive/bootstrap.js:49-74 sends STATIC_ASSETS once, at startup, and never again.
Reproduce
- Use the playground example "Interactive Instrument with Static Assets", changed so the
<img src="smiley.png">is inserted on a button click instead of being in the initial HTML. - Open it in
apps/webin Chrome. - Wait more than 30 s without interacting, or click "stop" for the worker under DevTools > Application > Service workers, which does the same as an idle termination. Then click the button.
Actual: the restarted worker has an empty staticAssets map, /runtime/v1/@opendatacapture/runtime-internal/interactive/smiley.png goes to the server, and the image is broken.
Expected: the asset is served however long the task has been running.
Tests
packages/runtime-internal/src/interactive/__tests__/worker.test.ts: it('should still serve registered assets after the worker script is re-evaluated, so an idle termination does not lose them'). Load the assets, call vi.resetModules() and re-import worker.js to simulate a restart, then fetch. This needs a stubbed caches (Cache Storage) in the test globals.
e2e, in testing/src/specs/instrument-completion.spec.ts: open an interactive instrument with static assets, stop its service worker through CDP (ServiceWorker.stopWorker), then trigger an asset request and assert it loads.
Suggested fix
Persist the assets where a restarted worker can read them. On STATIC_ASSETS, write each one as a Response into a named Cache Storage cache (caches.open(...)), and acknowledge only after the writes resolve. In fetch, respond from caches.match(pathname) and fall back to the network on a miss. Clear the cache whenever a new STATIC_ASSETS message arrives, so one instrument's assets are never served to the next.
- Lenguaje dominante
- TypeScript
- Estrellas
- 119
- Forks
- 19
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 44
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de DouglasNeuroInformatics/OpenDataCapture
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
DouglasNeuroInformatics/OpenDataCapture#1813 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
DouglasNeuroInformatics/OpenDataCapture#1812 ·
Los mantenedores suelen responder en 1 día
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
Los mantenedores suelen responder en 1 día
-
Area: Instruments Bug Difficulty: Low Priority: Low
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
Los mantenedores suelen responder en 1 día
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
Los mantenedores suelen responder en 1 día
Todos los issues de DouglasNeuroInformatics/OpenDataCapture
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
umami-software/umami#4637 ·
Los mantenedores suelen responder en 3 días
-
Hotkeys fire when pressed with the Ctrl key, so browser shortcuts also trigger player actionsPosiblemente ocupada @RaphaelFakhri la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
muxinc/media-chrome#1332 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
polarsource/polar#15580 ·
Los mantenedores suelen responder en 1 día
-
accepted bug via-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
pingdotgg/t3code#20931 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug/1-unconfirmed kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día