Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Make container reuse safe across processes

Aperta
#1,553 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, node.js, typescript
Ambito
devtools, testing

Direzione di ricerca

Read reuseOrStartContainer in packages/testcontainers/src/generic-container/generic-container.ts and the existing withFileLock implementation in packages/testcontainers/src/common/file-lock.ts. Check the tests for reusable container startup and run the relevant test suite with multiple processes to reproduce the race. Done means concurrent callers on the same host share one container; the issue notes that #1522 and #1552 also change this function, so coordinate around that overlap.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement minor

What happens

withReuse() looks for an existing container and creates one if there is none. That lookup-then-create is guarded by an in-process lock (AsyncLock), so two processes can both find nothing and both create a container.

Test runners commonly run test files in separate processes or workers. Starting the same reusable configuration from three processes at once created two containers. The extra one is never cleaned up, because reusable containers carry no session label.

Expected

Lookup-or-create is atomic across processes on the same host, so concurrent callers end up sharing one container.

Where

reuseOrStartContainer in packages/testcontainers/src/generic-container/generic-container.ts.

Notes

  • withFileLock in packages/testcontainers/src/common/file-lock.ts already serialises Ryuk and SSHD startup across processes. The same mechanism fits here.
  • Related: #1172, where the answer was to use the test runner's global setup. That remains the better fit for one shared container, but withReuse() is also used to keep containers between runs, where the race still applies.
  • Reproduced on main (aa60a746, 12.2.0) with Docker 29.6.1.

Dependencies

  • Stack on #1522, #1552: all three rewrite reuseOrStartContainer.
Lingua principale
TypeScript
Stelle
2.6k
Fork
274
Merge medio
1g 14h
PR unite (30g)
44

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di testcontainers/testcontainers-node

Tutte le issue di testcontainers/testcontainers-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.