Skip to content

Commit

Permalink
fix: make stack traces in FDR json formatted (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Apr 7, 2024
1 parent 9cb243b commit 57387c4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions servers/fdr/src/app/FdrApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,18 @@ export class FdrApplication {
};
this.dao = new FdrDao(prisma);
this.docsDefinitionCache = new DocsDefinitionCacheImpl(this, this.dao);

if ("prepareStackTrace" in Error) {
Error.prepareStackTrace = (err, stack) =>
JSON.stringify({
message: err.message,
stack: stack.map((frame) => ({
file: frame.getFileName(),
function: frame.getFunctionName(),
column: frame.getColumnNumber(),
line: frame.getLineNumber(),
})),
});
}
}
}
3 changes: 1 addition & 2 deletions servers/fdr/src/controllers/docs/v1/getDocsWriteService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { convertDocsDefinitionToDb } from "@fern-api/fdr-sdk";
import { v4 as uuidv4 } from "uuid";
import { DocsV1Write, DocsV1WriteService, FdrAPI } from "../../../api";
import type { FdrApplication } from "../../../app";
import { LOGGER } from "../../../app/FdrApplication";
import { type S3FileInfo } from "../../../services/s3";
import { writeBuffer } from "../../../util";

Expand Down Expand Up @@ -54,7 +53,7 @@ export function getDocsWriteService(app: FdrApplication): DocsV1WriteService {
writeShape: req.body.docsDefinition,
files: docsRegistrationInfo.s3FileInfos,
});
LOGGER.info(
app.logger.info(
`Docs for ${docsRegistrationInfo.orgId} has references to apis ${Array.from(
dbDocsDefinition.referencedApis,
).join(", ")}`,
Expand Down

0 comments on commit 57387c4

Please sign in to comment.