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

fix(gcs): Fix accessing promise index instead of index' result #66

Merged

Conversation

CaporalDead
Copy link
Contributor

Summary:

There is a priority problem between the promise/await and array access. Fix this by prioritizing the promise result over then array access. It was causing the following error :

/home/XXXXX/project/src/applications/business/XXXX.ts:5
import {useStorage} from "../../storage";
                                                         ^
Error: An error occurred while trying to generate a signed URL
    at /home/XXXXX/project/src/applications/business/XXXX.ts:114:15
    at Generator.next (<anonymous>)
    at fulfilled (/home/XXXXX/project/src/applications/business/XXXX.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

The code to reproduce

const storage = new Storage({
  type: StorageType.GCS,
  keyFilename: '/path/key.json',
  bucketName: 'my-bucket',
});

await storage.getFileAsURL(data.file.path, {
  useSignedUrl: true,
  expiresOn: Date.now() + 1000 * 60 * 60, // one hour
});

Tested on

Node 20.12.2
NPM 10.5.0

@abudaan abudaan merged commit 985581f into tweedegolf:master Jun 10, 2024
3 checks passed
@CaporalDead CaporalDead deleted the fix/gcs-force-index-on-promise-result branch June 10, 2024 13:58
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.

2 participants