Closed techieshark closed 3 years ago
Hi. I'm sorry @techieshark, this GitHub repo is not meant to file bugs against Cloud Functions. It's used to track issues directly in this npm module.
I don't know of this issue off hand.
For looking at the container, I believe you can build the container with Buildpacks and then use dive to inspect it:
https://cloud.google.com/functions/docs/building/pack https://github.com/wagoodman/dive
For general support, please use this:
Hi @grant thanks for the quick response.
I'll take a look at the "pack" and "dive" links you shared and see if that helps for debugging. Really appreciate the pointers!
For the benefit of others who might land here, I found this open issue in the Google Issue Tracker which would suggest cloud functions doesn't actually support using GitHub package repo:
Thanks again @grant - the tip to use pack
helped me sort out the issue, which wasn't that GitHub packages couldn't be installed, despite the Stackdriver log which seemed to indicate that.
For the sake of anyone landing here, I'll describe what I did.
First, build the cloud functions docker image (replace "myEntryPointFunction" with your entry point)
pack build --builder gcr.io/buildpacks/builder:v1 --env GOOGLE_RUNTIME=nodejs --env GOOGLE_FUNCTION_SIGNATURE_TYPE=http --env GOOGLE_FUNCTION_TARGET=myEntryPointFunction your_cloud_function_image
Then open a shell in it:
docker run -it --entrypoint /bin/bash your_cloud_function_image
Inside the docker image, cd to /workspace and look around. Tip: Node is installed in a funny location (find / -name node turned it up in /layers/google.nodejs.runtime/node/bin/node
).
Strangely, I got a very different error when trying to run the code (vs what I saw in Stackdriver log):
(So it turned out the issue was not that the entire module was missing - or that it wasn't installed from GitHub packages - but that I had the wrong file pointed to by the "main" field in the module's package.json.)
I hpoe this might help others. Thanks again for the tip!
Summary
I've been getting an inexplicable error during deployment and I'm unable to debug it.
I have a private monorepo and am publishing individual private packages to it using GitHub Packages. It seems Cloud Build is able to fetch the package ("yarn" works fine) but it seems that package is mysteriously missing when the function actually executes. What am I missing?
Details
I have a
.npmrc
which looks like:In
package.json
, I have:I then have some npm scripts I run to deploy:
When deploying, it seems the build phase works. The private package from the GitHub package repo seems to install - I can verify that by adding a
postinstall
script which just doesls node_modules/@myGithubOrgScopeName/
:Furthermore, I see no issues when viewing the Cloud Build logs via the url shown during the execution of
gcloud functions deploy
:If it helps, here's the build id shown in the legacy logs viewer filter settings:
However, the overall deploy fails ("on loading user code"):
When I go to Stackdriver Logs > Cloud Function > my function, I see that the module which should be from the GitHub package repo is not present (what?? it was there during deploy!).
Finally, I'm not sure how to further debug this, since:
a) The "Download Zip" feature on cloud functions console does not include the
node_modules/
, and also b) it does include package.json and I can confirm that my desired package is in fact listed as a dependency (contrary to what the logs' suggestion indicates as a potential problem).Is there a way, via the functions framework, to deploy to a local container I could then inspect? Or any other suggestions for how to fix this or what I might be doing wrong?
Thanks!