Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
TysonAndre-tmg opened this issue Jan 3, 2024 · 0 comments

Comments

@TysonAndre-tmg
Copy link

TysonAndre-tmg commented Jan 3, 2024

Problem: dynamodb-local may fail to download the dependencies of the jar (in DynamoDBLocal_lib) or the Node.js process may exit before the jar download is finished (or the https download may fail before it finishes), e.g. if there is a unit test timeout and the process exits before everything finish.

The fact that this is using pipe() to reduce memory usage (instead of waiting for the full download) makes it more likely that a folder will be created with incompletely extracted contents, though the bug could happen even without pipe (e.g. slow disk writes)

On slow internet connections or when a computer is under high load, this error can be more frequent.

Proposed solution

  1. Create a unique stub file with an arbitrary unique name such as dynamodb-local-downloaded-successfully.txt before calling deferred.resolve() on success
  2. Check that both the jar file and dynamodb-local-downloaded-successfully.txt exist before returning early.

(The first time libraries/applications using dynamodb-local update to a library version with this, they'll redownload dynamodb-local, but that should be fine)

Relevant parts of the code

  1. if (fs.existsSync(path.join(Config.installPath, JARNAME))) {
  2. dynamodb-local/index.js

    Lines 167 to 172 in b180b19

    redirectResponse
    .pipe(zlib.Unzip())
    .pipe(tar.extract({cwd: Config.installPath}))
    .on('end', function () {
    deferred.resolve();
    })

Related to #38 and #30

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

No branches or pull requests

1 participant