Skip to content

Failed chunk upload callback response is undefined error #142

@luis-tan

Description

@luis-tan

If a chunk upload fails and the failed chunk upload callback is triggered, the preceding check accounts for the response potentially being undefined, but the callback itself does not.

This actually caused an issue in our production code where we couldn't even notify the user an error had ocurred because the "error" dispatch event never happened.

Here's the offending line:
https://github.com/muxinc/upchunk/blob/master/src/upchunk.ts#L749

I'm happy to open a PR, but couldn't find a contributions document. The message could simply be ammended to something along the lines of:

      const message = res ? `Server responded with ${res.statusCode}. Stopping upload.` : 'Unable to connect with server. Stopping upload.';

      this.dispatch('error', {
        message,
        chunk: this.chunkCount,
        attempts: this.attemptCount,
        response: res,
      });

It's unclear what caused the error in the first place, but at least this way I can show a message to the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions