mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #2537 from omnivore-app/fix/set-headers-after-send
move sentry error handler after apollo middleware
This commit is contained in:
commit
909dce7e18
5 changed files with 16 additions and 5 deletions
|
|
@ -104,7 +104,7 @@ export function makeApolloServer(): ApolloServer {
|
|||
schema: schema,
|
||||
context: contextFunc,
|
||||
formatError: (err) => {
|
||||
console.log('server error', err)
|
||||
logger.info('server error', err)
|
||||
Sentry.captureException(err)
|
||||
// hide error messages from frontend on prod
|
||||
return new Error('Unexpected server error')
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export function webhooksServiceRouter() {
|
|||
[type]: data,
|
||||
})
|
||||
|
||||
console.log('triggering webhook', url, method, body)
|
||||
console.log('triggering webhook', url)
|
||||
await axios.request({
|
||||
url,
|
||||
method,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export const createPageSaveRequest = async ({
|
|||
// create processing page
|
||||
const pageId = await createPage(page, ctx)
|
||||
if (!pageId) {
|
||||
console.log('Failed to create page', page)
|
||||
console.log('Failed to create page', url)
|
||||
return Promise.reject({
|
||||
errorCode: CreateArticleSavingRequestErrorCode.BadData,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -55,6 +55,17 @@ function localConfig(id: string): ConsoleTransportOptions {
|
|||
}
|
||||
}
|
||||
|
||||
class GcpLoggingTransport extends LoggingWinston {
|
||||
log(info: any, callback: (err: Error | null, apiResponse?: any) => void) {
|
||||
const infoString = JSON.stringify(info)
|
||||
if (infoString.length > 250000) {
|
||||
// max size for a log entry is 256KB
|
||||
info = infoString.substring(0, 256000)
|
||||
}
|
||||
super.log(info, callback)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a logger with common options, including a transport for GCP when running in the cloud.
|
||||
* @param id Name of the log stream.
|
||||
|
|
@ -72,7 +83,7 @@ export function buildLogger(id: string, options?: LoggerOptions): Logger {
|
|||
export function buildLoggerTransport(id: string): TransportStream {
|
||||
return env.dev.isLocal
|
||||
? new transports.Console(localConfig(id))
|
||||
: new LoggingWinston({ ...googleConfigs, ...{ logName: id } })
|
||||
: new GcpLoggingTransport({ ...googleConfigs, ...{ logName: id } })
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ export const parsePageMetadata = (html: string): Metadata | undefined => {
|
|||
|
||||
return { title, author, description, previewImage }
|
||||
} catch (e) {
|
||||
console.log('failed to parse page:', html, e)
|
||||
console.log('failed to parse page:', e)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue