Skip to content

[cache] Uncaught Exception raised in uploadFile #612

@Swatinem

Description

@Swatinem

Describe the bug

The uploadFile / uploadChunk code throws inside of a node stream callback (.on('error')), which is not propagated properly through the async functions and leads to failures even though all cache calls are wrapped in try/catch.

.on('error', error => {
throw new Error(
`Cache upload failed because file read failed with ${error.message}`
)
}),

To Reproduce

Not quite sure, I think there was something wrong with the infrastructure or whatever. I got these failures on both Windows and macOS:

https://github.com/getsentry/sentry-rust/runs/1283097472

Warning:  uploadChunk (start: 234881024, end: 268435455) failed: write EPIPE
/Users/runner/work/_actions/Swatinem/rust-cache/v1/dist/save/index.js:339
                        throw new Error(`Cache upload failed because file read failed with ${error.message}`);
                        ^

Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
    at ReadStream.<anonymous> (/Users/runner/work/_actions/Swatinem/rust-cache/v1/dist/save/index.js:339:31)
    at ReadStream.emit (events.js:210:5)
    at internal/fs/streams.js:167:12
    at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5)

Expected behavior
There should be no unhandled exception being raised outside the promise chain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcache

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions