Skip to content

fix: prevent race condition in tar extraction with install marker#59

Open
abhu85 wants to merge 1 commit into
rynop:masterfrom
abhu85:fix-extraction-race-condition
Open

fix: prevent race condition in tar extraction with install marker#59
abhu85 wants to merge 1 commit into
rynop:masterfrom
abhu85:fix-extraction-race-condition

Conversation

@abhu85
Copy link
Copy Markdown

@abhu85 abhu85 commented Mar 16, 2026

Summary

Fixes #50 - Adds an installation marker file to ensure tar extraction completed successfully before returning.

Problem

The previous implementation only checked for the presence of DynamoDBLocal.jar to determine if installation was complete. This caused intermittent failures when:

  1. A previous download/extraction was interrupted (network timeout, process exit, slow disk)
  2. The jar file exists but DynamoDBLocal_lib/ directory is incomplete
  3. Tar stream events fired before disk writes fully completed

Users reported errors like "Invalid or corrupt jarfile DynamoDBLocal.jar" (#30) and "Unable to initialize main class" (#38) due to incomplete installations being used.

Solution

  1. Install marker file: Creates .dynamodb-local-install-complete only after extraction is verified successful
  2. Dual check: Checks for both jar file AND marker before skipping installation
  3. Clean reinstall: Removes incomplete installations before re-downloading
  4. Verification: Confirms jar file exists before creating the marker

Changes

  • Added INSTALL_MARKER constant for the marker filename
  • Updated installDynamoDbLocal() to check for both jar and marker
  • Added cleanup of incomplete installations with fs.rmSync()
  • Added onExtractionComplete() handler that verifies and creates marker
  • Uses { recursive: true } for directory creation

Test plan

  • Module loads successfully
  • Syntax validation passes
  • Maintains backward compatibility (first run will re-download, subsequent runs use marker)

Notes

Existing users will re-download DynamoDB Local once after this update (since marker file won't exist), but this is a one-time cost that ensures installation integrity.

The previous implementation only checked for the presence of the jar
file to determine if installation was complete. This could lead to
issues when:

1. A previous download/extraction was interrupted (network timeout,
   process exit, slow disk)
2. The jar file exists but DynamoDBLocal_lib is incomplete
3. The extraction completed for tar events but disk writes are pending

This fix:
- Adds a marker file (.dynamodb-local-install-complete) that is only
  created after successful extraction
- Checks for both the jar file AND marker file before skipping install
- Cleans up incomplete installations before re-downloading
- Verifies the jar file exists before creating the marker

Fixes rynop#50

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check if dynamodb-local tar file extraction is **completely** finished before resolving Promise

1 participant