Found this bug a couple weeks ago when Thiago was debugging a bad node v4 app on flex.
Repro steps
Create a v4 app
Use Node 20
Delete the http trigger code and add throw new Error('test'); instead
Run your app
Wait a while then check app insights & kusto
Expected
The error shows up in customer's app insights and our kusto
Actual
The error only shows up in customer's app insights, but not kusto
More info
Today, we save app startup errors that happen during workerInitRequest and return them during functionsMetadataRequest or functionLoadRequest instead (which also logs them - which is what I care about for this PR). However, if the error happens for a v4 app before the v4 model is registered in user code, we skip sending the error during functionsMetadataRequest because we think it's a v3 app and the host never sends a functionLoadRequest which only applies to v3 apps.
My fix is to always log the error right away and set a flag to prevent it from potentially being duplicated later.
Found this bug a couple weeks ago when Thiago was debugging a bad node v4 app on flex.
Repro steps
throw new Error('test');
insteadExpected
The error shows up in customer's app insights and our kusto
Actual
The error only shows up in customer's app insights, but not kusto
More info
Today, we save app startup errors that happen during workerInitRequest and return them during functionsMetadataRequest or functionLoadRequest instead (which also logs them - which is what I care about for this PR). However, if the error happens for a v4 app before the v4 model is registered in user code, we skip sending the error during functionsMetadataRequest because we think it's a v3 app and the host never sends a functionLoadRequest which only applies to v3 apps.
My fix is to always log the error right away and set a flag to prevent it from potentially being duplicated later.