feat: log thumb gen errors

This commit is contained in:
Adhiraj Singh
2022-09-12 12:15:34 +05:30
parent c20865dff1
commit 64f3f08adb
2 changed files with 9 additions and 2 deletions

View File

@@ -607,7 +607,8 @@ export const makeMessagesSocket = (config: SocketConfig) => {
userJid,
getUrlInfo: text => getUrlInfo(
text,
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 }
{ thumbnailWidth: linkPreviewImageThumbnailWidth, timeoutMs: 3_000 },
logger
),
upload: waUploadToServer,
mediaCache: config.mediaCache,

View File

@@ -1,3 +1,4 @@
import { Logger } from 'pino'
import { WAUrlInfo } from '../Types'
import { extractImageThumb, getHttpStream } from './messages-media'
@@ -23,7 +24,8 @@ export type URLGenerationOptions = {
*/
export const getUrlInfo = async(
text: string,
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 }
opts: URLGenerationOptions = { thumbnailWidth: THUMBNAIL_WIDTH_PX, timeoutMs: 3000 },
logger?: Logger
): Promise<WAUrlInfo | undefined> => {
try {
const { getLinkPreview } = await import('link-preview-js')
@@ -42,6 +44,10 @@ export const getUrlInfo = async(
? await getCompressedJpegThumbnail(image, opts)
: undefined
} catch(error) {
logger?.debug(
{ err: error.stack, url: previewLink },
'error in generating thumbnail'
)
}
return {