Spurious precondition failures caused by ifGenerationMatch preserved across save() calls
See original GitHub issueBlocked
- https://github.com/googleapis/gcs-resumable-upload/pull/243
- https://github.com/googleapis/gcs-resumable-upload/pull/244
I’m using file('example', { generation: 0 }).save()
and discovered a strange behavior. I’ve managed to get resumable saves stuck in my config store, and as a result, when I subsequently invoke file('example').save()
, the ifGenerationMatch
header is still present on the response.
This is caused by the resumable upload code, which is turned on by default. I’m not sure whether the bug is here or in that library.
Steps to reproduce:
const bucket = new Storage({ projectId }).bucket(bucketName)
await bucket.file('example').save('hello', { resumable: false })
try {
await bucket.file('example', { generation: 0 }).save('hello')
} catch (e) {
// Catch a precondition failure
}
// Saves a new version as expected.
await bucket.file('example').save('hello', { resumable: false })
// Expected to save a new version, but throws precondition failure
await bucket.file('example').save('hello')
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Request preconditions | Cloud Storage
This page discusses request preconditions, which you use to prevent requests from applying to a resource when the resource is in an unexpected...
Read more >Write file and then upload to cloud storage - NodeJS
If you confirmed that the file is saved locally and just want to upload it to the bucket, you may refer to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have sent a PR: https://github.com/googleapis/gcs-resumable-upload/pull/243
And a PR to expose
uploadInstance.deleteConfig()
: https://github.com/googleapis/gcs-resumable-upload/pull/244. This will have to be re-exposed through the Storage API after it ships in gcs-resumable-upload.