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

Can't upload from inside Cloud Function #2191

Closed
savager opened this issue May 3, 2023 · 4 comments
Closed

Can't upload from inside Cloud Function #2191

savager opened this issue May 3, 2023 · 4 comments
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@savager
Copy link

savager commented May 3, 2023

"Error: TypeError: Expected signal to be an instanceof AbortSignal
    at /workspace/index.js:2:1801556
    at /workspace/index.js:2:1799686
    at Object.throw (/workspace/index.js:2:1799791)
    at s (/workspace/index.js:2:1798559)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)"

Environment details

  • OS: Cloud function
  • Node.js version: 14
  • npm version: using pnpm
  • @google-cloud/storage version: "^6.10.0",

Steps to reproduce

Can't produce locally. But when I push the compiled JS file to the cloud function I get this error

I believe it has to do with bundling the code with webpack. If I don't install request manually, I get this error:

WARNING in ../../node_modules/.pnpm/retry-request@5.0.2/node_modules/retry-request/index.js 76:21-39
Module not found: Error: Can't resolve 'request' in '/Users/*****/Projects/project/node_modules/.pnpm/retry-request@5.0.2/node_modules/retry-request'

If i add request as a dep, then I get the AbortSignal error.

the package request is deprecated, and I think it should be removed as a dep.

@savager savager added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 3, 2023
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label May 3, 2023
@savager
Copy link
Author

savager commented May 3, 2023

Disabling Webpack 5 minification solves this issue.

@savager savager closed this as completed May 3, 2023
@mbrevda
Copy link

mbrevda commented May 15, 2023

Just noticed the same when using esbuild. Is there a way to fix?

@mbrevda
Copy link

mbrevda commented May 15, 2023

Look like this is coming from the teeny-request dependency, an issue is outstanding here: googleapis/teeny-request#260

@Shakahs
Copy link

Shakahs commented Dec 22, 2023

@mbrevda for esbuild I used the --external option to exclude @google-cloud/storage (actually firebase-admin) from my bundle.

esbuild --bundle src/index.ts --outfile=lib/index.cjs --platform=node --target=node20 --sourcemap --external:firebase-admin

Even though the code is bundled by esbuild prior to upload, Cloud Functions is still doing npm install, so all the dependencies of the bundled code including firebase-admin are available for normal module resolution in the function's node_modules directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants