Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export interface AzFuncError {
* User errors cannot be tracked in our telemetry because they could have user information (users can still track it themselves in their app insights resource)
*/
isAzureFunctionsSystemError: boolean;

alreadyLoggedOverRpc?: boolean;
}

export interface ValidatedError extends Error, Partial<AzFuncError> {
Expand Down
2 changes: 1 addition & 1 deletion src/setupEventStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async function handleMessage(inMsg: rpc.StreamingMessage): Promise<void> {
outMsg[eventHandler.responseName] = response;
} catch (err) {
const error = ensureErrorType(err);
if (error.isAzureFunctionsSystemError) {
if (error.isAzureFunctionsSystemError && !error.alreadyLoggedOverRpc) {
worker.log({
message: error.message,
level: LogLevel.Error,
Expand Down
15 changes: 9 additions & 6 deletions src/startApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ async function loadEntryPointFile(functionAppDirectory: string): Promise<void> {
console.error(error.stack);
} else {
// In this case, the error will never block the app
// The most we can do without breaking backwards compatibility is log it as a system log
worker.log({
message: newMessage,
level: LogLevel.Error,
logCategory: LogCategory.System,
});
// The most we can do without breaking backwards compatibility is log it as an rpc system log below
}

// Always log as rpc system log, which goes to our internal telemetry
worker.log({
message: newMessage,
level: LogLevel.Error,
logCategory: LogCategory.System,
});
error.alreadyLoggedOverRpc = true;
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions test/startApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ describe('startApp', () => {

stream.addTestMessage(msg.init.request(testAppPath));
if (fileSubpath.includes('missing')) {
await stream.assertCalledWith(msg.init.receivedRequestLog, msg.init.response);
await stream.assertCalledWith(msg.init.receivedRequestLog, msg.errorLog(errorMessage), msg.init.response);
} else {
await stream.assertCalledWith(
msg.init.receivedRequestLog,
msg.loadingEntryPoint(fileSubpath),
msg.errorLog(errorMessage),
msg.init.response
);
}
Expand All @@ -66,19 +67,14 @@ describe('startApp', () => {
if (isModelV4) {
await stream.assertCalledWith(
msg.indexing.receivedRequestLog,
msg.errorLog(errorMessage),
msg.indexing.failedResponse(errorMessage, false)
);
} else {
await stream.assertCalledWith(msg.indexing.receivedRequestLog, msg.indexing.response([], true));
}

stream.addTestMessage(msg.funcLoad.request('helloWorld.js'));
await stream.assertCalledWith(
msg.funcLoad.receivedRequestLog,
msg.errorLog(errorMessage),
msg.funcLoad.failedResponse(errorMessage)
);
await stream.assertCalledWith(msg.funcLoad.receivedRequestLog, msg.funcLoad.failedResponse(errorMessage));
}

describe('Node >=v20', () => {
Expand Down