Skip to content

Conversation

@ejizba
Copy link
Contributor

@ejizba ejizba commented May 27, 2023

And make this behavior the default starting with Node v20. For Node <v20, we'll provide an app setting FUNCTIONS_NODE_BLOCK_ON_ENTRY_POINT_ERROR to configure this.

There's still an edge case where you get an error before you've registered v4 as the programming model. Not much we can do about that for Node <20 because of #630, though

Fixes Azure/azure-functions-nodejs-library#85
Fixes #697

@ejizba ejizba requested a review from hossam-nasr May 27, 2023 00:57
hossam-nasr
hossam-nasr previously approved these changes May 31, 2023
And provide an app setting to configure this behavior regardless of model version
@ejizba ejizba force-pushed the ej/startAppError branch from 27cd152 to 9b3e7d7 Compare May 31, 2023 22:06
@ejizba ejizba requested a review from hossam-nasr June 23, 2023 22:17
@ejizba ejizba dismissed hossam-nasr’s stale review June 23, 2023 22:17

Updated per offline sync regarding Node 20

@ejizba
Copy link
Contributor Author

ejizba commented Jul 11, 2023

A few updates after going back and forth with Brett on the host team. I was able to get an "end-to-end" scenario tested in Azure and I feel more comfortable with the overall experience now. Two main changes:

  1. Log the error using console.log, which will forward the most important worker errors to a user's app insights
  2. Don't throw the error during worker init or function environment reload, because the host interprets these failures as "system" errors (aka problem with the worker itself) and gets into a pretty broken state. Instead, throw the error in functionMetadata or functionLoad, which the host interprets as "user" errors (aka a problem with the user's code) and it handles it much better. A few example problems if we throw the error during worker init request:
    1. The portal won't show app keys - it will just load indefinitely
    2. The host will retry loading the worker, and end up sending a bunch of unhelpful errors to the user's app insights like "Error: 14 UNAVAILABLE"
    3. If you try to execute a function in the old model (with the "block" app setting turned on), the host will return a generic 404 error and nothing helpful in the exceptions table in app insights. If we throw the app start error during function load, the host will know to associate that with the execution and surface it in the exceptions table for app insights. (This only applies to the old model, because in that case the host loaded the functions before the app start error occured. In the new model, the app start error occurs before the worker can load the functions.)

src/startApp.ts Outdated
// Instead, it will be thrown during functionMetadata or functionLoad response which better indicates that the user's app is the problem
worker.app.blockingAppStartError = error;
// This will ensure the error makes it to the user's app insights
console.log(error.stack);
Copy link
Contributor

@hossam-nasr hossam-nasr Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make a difference here logging using console.log vs console.error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought they were the same, but console.error might result in a more accurate severityLevel in app insights. Let me try it out and get back to you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah had a better severity level, thanks. Updated

@ejizba ejizba merged commit 587a972 into v3.x Jul 14, 2023
@ejizba ejizba deleted the ej/startAppError branch July 14, 2023 00: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.

Entry point errors should block app from running Make v4 entry point failures more obvious

2 participants