serve-instrument exits when an instrument directory is deleted or a request URL has a malformed percent-escape
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- node.js, typescript
Direzione di ricerca
Start with packages/serve-instrument/src/server.tsx at the watcher callback, updateEncodedBundle, request handler, and URL decoding points named in the issue. Then read packages/serve-instrument/src/__tests__/server.test.ts and run the focused tests. Done when the deletion and malformed-URL cases return the expected responses without stopping the server or disrupting other instruments.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
serve-instrument exits with an unhandled error when an instrument directory is deleted or renamed while it runs, or when it receives a URL with a malformed percent-escape. In both cases an exception escapes an async function that is called with void: this.handler.handle(...) for requests, and this.updateEncodedBundle() in the fs.watch callback. Node turns the unhandled rejection into a process exit. In updateEncodedBundle, only the bundle() call is inside the try; the readdir/readFile before it are not. In --all mode, deleting or renaming one instrument folder kills the server for all the others, and so does a git checkout that removes one. An author has to notice that the terminal died and restart it.
Where
packages/serve-instrument/src/server.tsx:45-48, 62-79 and 243-247, 312:
this.watcher = fs.watch(target, { recursive: false }, () => {
// ...
void this.updateEncodedBundle();
});
// ...
private async updateEncodedBundle(): Promise<void> {
const inputs: BundlerInput[] = [];
const filepaths = await fs.promises
.readdir(this.target, 'utf-8')
// ...
for (const filepath of filepaths) {
const loader = inferLoader(filepath);
const content: string | Uint8Array = await fs.promises.readFile(filepath, /* ... */);
// ...
}
const start = Date.now();
try {
// ...
const decodedName = decodeURIComponent(name!);
// ...
this.server = http.createServer((...args) => void this.handler.handle(...args));
Reproduce
- Build it (
pnpm --filter @opendatacapture/serve-instrument build) and runnode dist/cli.js --all <dir>on a directory containingforms/FOO/index.tsandforms/BAR/index.ts. - Open
/forms/BAR, thenrm -rf <dir>/forms/BAR.
Actual:↺ [forms/BAR] File changed, rebuilding..., thenError: ENOENT: no such file or directory, scandir '…/forms/BAR'and the process exits (verified onmain)./forms/FOOis no longer served. - Restart, then
curl 'http://localhost:3000/forms/%E0%A4%A'.
Actual:URIError: URI malformedatdecodeURIComponentand the process exits (verified onmain).
Expected: the server logs the failure and keeps running. A deleted instrument answers 404 and a malformed URL answers 400.
Tests
packages/serve-instrument/src/__tests__/server.test.ts:
it('should keep serving other instruments after an instrument directory is deleted, so a rebuild failure does not kill the server'): fire the captured watch callback after removing the temp directory, and assert that the remaining instrument still returns 200.it('should answer 400 to a malformed percent-escape in an instrument URL rather than crashing')
No e2e test applies: serve-instrument is not part of the stack under testing/.
Suggested fix
Move the directory listing and file reads inside the existing try in updateEncodedBundle. Wrap handle in Server's request callback with a .catch that logs the error and ends the response with 500 if headers are not yet sent. Map a URIError from decodeURIComponent to 400.
- Lingua principale
- TypeScript
- Stelle
- 119
- Fork
- 19
- Merge medio
- 1g 2h
- PR unite (30g)
- 56
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di DouglasNeuroInformatics/OpenDataCapture
-
Area: Playground Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1805 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
DouglasNeuroInformatics/OpenDataCapture#1801 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
DouglasNeuroInformatics/OpenDataCapture#1800 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Good First Issue Priority: Low
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
DouglasNeuroInformatics/OpenDataCapture#1799 ·
I maintainer di solito rispondono entro 1 giorno
-
Area: Instruments Bug Difficulty: Low Performance Priority: Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
DouglasNeuroInformatics/OpenDataCapture#1795 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di DouglasNeuroInformatics/OpenDataCapture
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
MystenLabs/MemWal#1163 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Mondriaan
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
knaw-huc/textannoviz#709 ·
I maintainer di solito rispondono entro 1 giorno
-
billion-context-pi
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ranxianglei/billion-context#2521 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Add: YRF Music NepalApertastreams:add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100