question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: issues deploying to Cloud Functions

See original GitHub issue

It is not clear what the actual firebase function should load in this case. Also, there is no sveltekit/ directory. I am assuming this is the build directory that svelte-kit build creates?

This is what I have in functions/src/index.ts, and I get a deployment error: Function failed on loading user code

const functions = require("firebase-functions");
const next = require("./build/index.js");
exports.ssr = functions.https.onRequest(next);

I also found two problems with build/index.js:

const app = require('./app.js'); 

// should be

const app = require(./app.cjs);

// and

const assets_handler = sirv('assets', {
	maxAge: 31536000,
	immutable: true
});

// is always an exact path, so it doesn't load correctly
// this works sometimes:

const assets_handler = sirv(__dirname + '/assets', {
	maxAge: 31536000,
	immutable: true
});

I am not sure what the firebase function should load, or how it should load it…

I feel like I am getting closer, but not sure what the code is supposed to be, and I func is not a function error when deploying…

Is this how the Firebase Function should look?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jdgamble555commented, Feb 10, 2021

And that fixed it. Don’t know how I did that. Thanks!

Just side note: It would be cool if you created the firebase function automatically like you have here, but actually create the function when you run deploy. Angular universal does this.

Thanks!

0reactions
jthegeduscommented, Feb 11, 2021

And that fixed it. Don’t know how I did that. Thanks!

Great!

It would be cool if you created the firebase function automatically

Given the history of people structuring their Functions every which way, I tried to reduce the restrictions and automation in favor of hints. The only requirement to make the log be quiet is that it finds a snippet of <functionName> =" in the index.js` output from the Functions dir.

I may look into an auto-generation option, but then I’d have to deal with find and replace on function renames etc. Since it is an event that isn’t going to occur often I think this is a good balance for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting Cloud Functions
Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. The...
Read more >
Cloud Function deployment using gcloud failing for updated ...
We made a small change to the code (it was a copy of existing code and tried to deploy. It failed with error...
Read more >
[BUG] Permission 'cloudfunctions.functions.list' denied #203
Yes, I have the same issue when try to deploy angular with server-side rendering function.
Read more >
"An unknown error has occurred" deploying google cloud ...
The issue is that now I'm getting "an unknown error has occurred" when I try to deploy a new function. I've tried to...
Read more >
Google Cloud Service Health
2020 ; Cloud Functions deployments in a new region failing globally, 9 Feb 2020. 5 hours, 31 minutes ; We've received a report...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found