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

@tus/s3-store: fix uncaught exception when cancelling an upload #412

Merged
merged 1 commit into from
Mar 14, 2023
Merged

@tus/s3-store: fix uncaught exception when cancelling an upload #412

merged 1 commit into from
Mar 14, 2023

Conversation

naumf
Copy link
Contributor

@naumf naumf commented Mar 14, 2023

Fixes #411

Copy link
Member

@Murderlon Murderlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Do you think we can test this easily in https://github.com/tus/tus-node-server/blob/main/packages/s3-store/test.ts? Would be nice a great case for a test.

@naumf
Copy link
Contributor Author

naumf commented Mar 14, 2023

I can't think of an easy way to test this.
I tested this with manual testing, once with the error event being handled and the other time the error event not being handled.

@Murderlon
Copy link
Member

Perhaps we can do something similar to this:

it('should reject when stream is destroyed', async function () {
const file = new Upload({
id: 'write-test-reject',
size: this.testFileSize,
offset: 0,
metadata: {filename: 'world_domination_plan.pdf', is_confidential: null},
})
await this.datastore.create(file)
const readable = new stream.Readable({
read() {
this.push('some data')
this.destroy()
},
})
const offset = this.datastore.write(readable, file.id, 0)
return offset.should.be.rejected()
})

Instead of destroy, we error and assert the error? Can we distinguish there between unexpected and expected?

@naumf
Copy link
Contributor Author

naumf commented Mar 14, 2023

I'm not sure if it is testable at all because of a possible race between reject and resolve:

@Murderlon Murderlon merged commit 6fc2255 into tus:main Mar 14, 2023
@Murderlon
Copy link
Member

Thank you!

@Murderlon
Copy link
Member

Murderlon added a commit to mitjap/tus-node-server that referenced this pull request May 16, 2023
* main:
  Bump typescript from 4.9.3 to 5.0.4 (tus#425)
  Bump sinon from 15.0.0 to 15.0.4 (tus#426)
  @tus/gcs-store: allow user to pass bucket instance to GCSStore (tus#388)
  Fix e2e test typecheking (tus#429)
  Update incorrect comment (tus#430)
  @tus/s3-store: add missing error code in termination extension (tus#413)
  @tus/s3-store@1.0.0-beta.5
  @tus/s3-store: fix uncaught exception when cancelling an upload (tus#412)
  @tus/s3-store@1.0.0-beta.4
  @tus/s3-store: fix uncaught exception when removing files (tus#410)
  @tus/s3-store: add termination extension (tus#401)
  @tus/server@1.0.0-beta.5
  Bump @google-cloud/storage from 6.8.0 to 6.9.3 (tus#404)
  Bump http-cache-semantics from 4.1.0 to 4.1.1 (tus#393)
  Bump eslint-config-prettier from 8.5.0 to 8.6.0 (tus#392)
  Bump cookiejar from 2.1.3 to 2.1.4 (tus#383)
  Bump aws-sdk from 2.1269.0 to 2.1325.0 (tus#403)
  @tus/server: refactor and improve request validator (tus#402)
  Fix demo (tus#386)
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.

Server crashes when an upload is cancelled
2 participants