Fix startup error not showing up in kusto #753
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.