From 1fba50400a1e8ececc10bbe8ea11cc8dcea2289c Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 14:05:03 +0330 Subject: [PATCH 1/6] feat: improve error debugging --- core/fetch/src/fetch.ts | 8 +++--- core/i18n/src/i18n.ts | 2 +- core/logger/README.md | 6 ++--- core/logger/src/type.ts | 4 +-- core/nano-server/src/nano-server.ts | 8 +++++- core/signal/src/core.ts | 6 ++--- core/storage-client/README.md | 2 +- core/storage-client/src/storage-client.ts | 19 +++++++------- demo/logger/index.ts | 2 +- demo/storage-client/benchmark.ts | 5 +--- services/comment/src/lib/storage.ts | 2 +- services/comment/src/route/patch.ts | 17 ++++++++++--- services/comment/src/route/storage.ts | 14 ++++++++--- services/flight-crawler/src/crawl.ts | 2 +- services/storage-server/demo.http | 4 +-- services/telegram-notifier/src/bot/launch.ts | 4 +-- .../telegram-notifier/src/bot/send-message.ts | 2 +- ui-kit/icon/src/icon.ts | 4 +-- .../flight-finder-api/src/route/job/delete.ts | 25 ++++++++++++------- .../flight-finder-api/src/route/job/get.ts | 10 ++++++-- .../flight-finder-api/src/route/job/put.ts | 10 ++++++-- 21 files changed, 97 insertions(+), 59 deletions(-) diff --git a/core/fetch/src/fetch.ts b/core/fetch/src/fetch.ts index f9131f71f..cf0d5346a 100644 --- a/core/fetch/src/fetch.ts +++ b/core/fetch/src/fetch.ts @@ -37,7 +37,7 @@ export async function serviceRequest, TMeta = Re response = await fetch(options); } catch (err) { - logger.error('serviceRequest', (err as Error).message || 'fetch_failed', (err as Error).stack || err, options); + logger.error('serviceRequest', 'fetch_failed', err, options); throw new Error('fetch_failed'); } @@ -46,7 +46,7 @@ export async function serviceRequest, TMeta = Re responseText = await response.text(); } catch (err) { - logger.error('serviceRequest', 'invalid_response', (err as Error).message || err, { + logger.error('serviceRequest', 'invalid_response', err, { response, }); throw new Error('invalid_response'); @@ -57,7 +57,7 @@ export async function serviceRequest, TMeta = Re responseJson = JSON.parse(responseText); } catch (err) { - logger.error('serviceRequest', 'invalid_json', (err as Error).message || err, {responseText}); + logger.error('serviceRequest', 'invalid_json', err, {responseText}); throw new Error('invalid_json'); } @@ -289,7 +289,7 @@ async function _handleRetryPattern(options: Required): Promise { } } catch (err) { - logger.error('resourceProvider', 'fetch_failed', (err as Error).stack || err, {locale, url}); + logger.error('resourceProvider', 'fetch_failed', err, {locale, url}); // TODO: user error signal. return; } diff --git a/core/logger/README.md b/core/logger/README.md index 8adaa1628..c4f148665 100644 --- a/core/logger/README.md +++ b/core/logger/README.md @@ -148,7 +148,7 @@ try { ... } catch (err) { - logger.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2}); + logger.error('myMethod', 'error_code', err, {a: 1, b: 2}); } ``` @@ -175,7 +175,7 @@ Best practices to catch the error and log it: ```ts // Unhandled promise rejection (just log it) failPromiseTest().catch((err) => - logger.error('myMethod', (err as Error).message || 'error_code', (err as Error).stack || err) + logger.error('myMethod', (err as Error).message || 'error_code', err) ); // Handled promise rejection @@ -186,7 +186,7 @@ try { 'myMethod', 'error_code', 'failPromiseTest failed!, ' + (err as Error).message, - (err as Error).stack || err + err ); // do something to handle the error... } diff --git a/core/logger/src/type.ts b/core/logger/src/type.ts index 25f6aac4c..ed6aa7fa7 100644 --- a/core/logger/src/type.ts +++ b/core/logger/src/type.ts @@ -127,11 +127,11 @@ export interface AlwatrLogger { * ... * } * catch (err) { - * logger.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2}); + * logger.error('myMethod', 'error_code', err, {a: 1, b: 2}); * } * ``` */ - error(method: string, code: string, errorStack: string | unknown, ...args: unknown[]): void; + error(method: string, code: string, ...args: unknown[]): void; /** * Simple `console.debug` with styled scope. diff --git a/core/nano-server/src/nano-server.ts b/core/nano-server/src/nano-server.ts index bd7602112..e10f9d0ff 100644 --- a/core/nano-server/src/nano-server.ts +++ b/core/nano-server/src/nano-server.ts @@ -247,7 +247,8 @@ export class AlwatrNanoServer { this._notFoundListener(connection); } } - catch (err) { + catch (_err) { + const err = _err as Error; this._logger.error('handleRequest', 'http_server_middleware_error', err, { method: connection.method, route, @@ -256,6 +257,11 @@ export class AlwatrNanoServer { ok: false, statusCode: 500, errorCode: 'http_server_middleware_error', + meta: { + name: err?.name, + message: err?.message, + cause: err?.cause, + }, }); } } diff --git a/core/signal/src/core.ts b/core/signal/src/core.ts index 61d5fabf5..5c436108e 100644 --- a/core/signal/src/core.ts +++ b/core/signal/src/core.ts @@ -68,14 +68,14 @@ function __callListeners(signal: SignalO const ret = listener.callback(signal.value); if (ret instanceof Promise) { ret.catch((err) => - logger.error('_callListeners', 'call_listener_failed', (err as Error).stack || err, { + logger.error('_callListeners', 'call_listener_failed', err, { signalName: signal.name, }), ); } } catch (err) { - logger.error('_callListeners', 'call_listener_failed', (err as Error).stack || err, { + logger.error('_callListeners', 'call_listener_failed', err, { signalName: signal.name, }); } @@ -129,7 +129,7 @@ export function _addSignalListener( listenerCallback(signal.value); } catch (err) { - logger.error('_addSignalListener', 'call_signal_callback_failed', (err as Error).stack || err, { + logger.error('_addSignalListener', 'call_signal_callback_failed', err, { signalName: signal.name, }); } diff --git a/core/storage-client/README.md b/core/storage-client/README.md index 9ba5fc584..91c831756 100644 --- a/core/storage-client/README.md +++ b/core/storage-client/README.md @@ -81,7 +81,7 @@ try { if ((err as Error)?.message === 'document_not_found') { console.log('user_5000 id not found!'); } else { - console.err((err as Error)?.message ?? err); + console.error(err); } } ``` diff --git a/core/storage-client/src/storage-client.ts b/core/storage-client/src/storage-client.ts index e54d64d48..102ef3032 100644 --- a/core/storage-client/src/storage-client.ts +++ b/core/storage-client/src/storage-client.ts @@ -61,7 +61,11 @@ alwatrRegisteredList.push({ * } */ export class AlwatrStorageClient { - protected _logger = createLogger('alwatr-storage-client:' + this.config.name, undefined, this.config.debug); + protected _logger = createLogger( + 'alwatr-storage-client' + (this.config.name == null ? '' : ':' + this.config.name), + undefined, + this.config.debug, + ); /** * Default fetch options. @@ -98,7 +102,7 @@ export class AlwatrStorageClient { - this._logger.logMethodArgs('get', {documentId}); + this._logger.logMethodArgs('get', {storage, documentId}); if (storage == null) throw new Error('storage_not_defined'); const responseJson = await serviceRequest({ @@ -118,10 +122,7 @@ export class AlwatrStorageClient { - this._logger.logMethodArgs('has', {documentId}); + this._logger.logMethodArgs('has', {storage, documentId}); if (storage == null) throw new Error('storage_not_defined'); const responseJson = await serviceRequest<{has: boolean | unknown}>({ @@ -212,7 +213,7 @@ export class AlwatrStorageClient { - this._logger.logMethodArgs('delete', {documentId}); + this._logger.logMethodArgs('delete', {storage, documentId}); if (storage == null) throw new Error('storage_not_defined'); await serviceRequest({ diff --git a/demo/logger/index.ts b/demo/logger/index.ts index cbacb8902..ea2aebe9b 100644 --- a/demo/logger/index.ts +++ b/demo/logger/index.ts @@ -34,5 +34,5 @@ try { throw new Error('my_error_message'); } catch (err) { - logger1.error('myMethod', 'error_code', (err as Error).stack || err, {a: 1, b: 2}); + logger1.error('myMethod', 'error_code', err, {a: 1, b: 2}); } diff --git a/demo/storage-client/benchmark.ts b/demo/storage-client/benchmark.ts index 9d8f9be16..18af3cd8f 100644 --- a/demo/storage-client/benchmark.ts +++ b/demo/storage-client/benchmark.ts @@ -12,10 +12,7 @@ interface User extends AlwatrDocumentObject { token: string; } -const token = process.env.TOKEN; -if (token == null) { - throw new Error('token_not_defined'); -} +const token = process.env.TOKEN ?? 'YOUR_SECRET_TOKEN'; const db = new AlwatrStorageClient({ name: 'junk-data', diff --git a/services/comment/src/lib/storage.ts b/services/comment/src/lib/storage.ts index fb3ae5180..a7fe7c4e9 100644 --- a/services/comment/src/lib/storage.ts +++ b/services/comment/src/lib/storage.ts @@ -3,4 +3,4 @@ import {AlwatrStorageClient} from '@alwatr/storage-client'; import {config} from '../config.js'; import {Message} from './type.js'; -export const storage = new AlwatrStorageClient(config.storage); +export const storageClient = new AlwatrStorageClient(config.storage); diff --git a/services/comment/src/route/patch.ts b/services/comment/src/route/patch.ts index 91377bc32..83fb7137c 100644 --- a/services/comment/src/route/patch.ts +++ b/services/comment/src/route/patch.ts @@ -1,6 +1,6 @@ import {config, logger} from '../config.js'; import {nanoServer} from '../lib/nano-server.js'; -import {storage} from '../lib/storage.js'; +import {storageClient} from '../lib/storage.js'; import {Message} from '../lib/type.js'; import type {AlwatrConnection} from '@alwatr/nano-server'; @@ -27,17 +27,26 @@ async function setComment(connection: AlwatrConnection): Promise { // } try { + const comment = await storageClient.set(bodyJson, params.storage); + logger.logProperty('comment', comment); + connection.reply({ ok: true, - data: await storage.set(bodyJson, params.storage), + data: comment, }); } - catch (err) { - logger.error('setComment', (err as Error).message ?? 'storage_error', (err as Error).stack ?? err); + catch (_err) { + const err = _err as Error; + logger.error('setComment', err.message || 'storage_error', err); connection.reply({ ok: false, statusCode: 500, errorCode: 'storage_error', + meta: { + name: err.name, + message: err.message, + cause: err.cause, + }, }); } } diff --git a/services/comment/src/route/storage.ts b/services/comment/src/route/storage.ts index f133a5542..709988f53 100644 --- a/services/comment/src/route/storage.ts +++ b/services/comment/src/route/storage.ts @@ -1,6 +1,6 @@ import {config, logger} from '../config.js'; import {nanoServer} from '../lib/nano-server.js'; -import {storage} from '../lib/storage.js'; +import {storageClient} from '../lib/storage.js'; import type {AlwatrConnection} from '@alwatr/nano-server'; @@ -16,14 +16,20 @@ async function getStorage(connection: AlwatrConnection): Promise { if (params == null) return; try { - connection.reply(await storage.getStorage(params.name)); + connection.reply(await storageClient.getStorage(params.name)); } - catch (err) { - logger.error('getStorage', (err as Error).message ?? 'storage_error', (err as Error).stack ?? err); + catch (_err) { + const err = _err as Error; + logger.error('getStorage', err.message || 'storage_error', err); connection.reply({ ok: false, statusCode: 500, errorCode: 'storage_error', + meta: { + name: err.name, + message: err.message, + cause: err.cause, + }, }); } } diff --git a/services/flight-crawler/src/crawl.ts b/services/flight-crawler/src/crawl.ts index e02f8a632..00de34750 100644 --- a/services/flight-crawler/src/crawl.ts +++ b/services/flight-crawler/src/crawl.ts @@ -25,7 +25,7 @@ export async function crawlAllJobs(): Promise { await storageClient.set(job); } catch (err) { - logger.error('crawlAllJobs', 's', (err as Error).stack); + logger.error('crawlAllJobs', 'crawling_failed', err); } } } diff --git a/services/storage-server/demo.http b/services/storage-server/demo.http index 579646354..c31e5ef6e 100644 --- a/services/storage-server/demo.http +++ b/services/storage-server/demo.http @@ -17,7 +17,7 @@ Content-Type: application/json { "id": "auto_increment", "from": "Ali Mihandoost", - "message": "Salam" + "message": "سلام" } ### @@ -28,7 +28,7 @@ Content-Type: application/json { "id": "auto_increment", "from": "Fateme Mihandoost", - "message": "Aleyk Salam" + "message": "علیک سلام" } ### Edit document diff --git a/services/telegram-notifier/src/bot/launch.ts b/services/telegram-notifier/src/bot/launch.ts index c12a57c61..666ce781f 100644 --- a/services/telegram-notifier/src/bot/launch.ts +++ b/services/telegram-notifier/src/bot/launch.ts @@ -9,12 +9,12 @@ export async function launchBot(): Promise { logger.logProperty('botInfo', bot.botInfo); bot.launch().catch((err) => { - logger.error('launchBot', 'launch_bot_failed', (err as Error).stack || err); + logger.error('launchBot', 'launch_bot_failed', err); }); await sendMessage(config.telegramBot.debugNotifyToken, '⚡️ Bot launched'); } catch (err) { - logger.error('launchBot', 'launch_bot_failed', (err as Error).stack || err); + logger.error('launchBot', 'launch_bot_failed', err); } } diff --git a/services/telegram-notifier/src/bot/send-message.ts b/services/telegram-notifier/src/bot/send-message.ts index fcdb8a0d0..e94a95fce 100644 --- a/services/telegram-notifier/src/bot/send-message.ts +++ b/services/telegram-notifier/src/bot/send-message.ts @@ -17,7 +17,7 @@ export async function sendMessage(to: string, message: string): Promise { } catch (err) { // TODO: handle blocked user - logger.error('sendMessage', 'error_send_message', (err as Error).stack || err, {chatId}); + logger.error('sendMessage', 'error_send_message', err, {chatId}); } } } diff --git a/ui-kit/icon/src/icon.ts b/ui-kit/icon/src/icon.ts index e118f1d23..118a2f8bf 100644 --- a/ui-kit/icon/src/icon.ts +++ b/ui-kit/icon/src/icon.ts @@ -84,8 +84,8 @@ export class AlwatrIcon extends AlwatrElement { try { this._icon = html`${unsafeSVG(await preloadIcon(this.name, this.urlPrefix))}`; } - catch (error) { - this._logger.error('_fetchIcon', 'fetch_failed', (error as Error).stack || error); + catch (err) { + this._logger.error('_fetchIcon', 'fetch_failed', err); this._icon = AlwatrIcon._fallback; } } diff --git a/uniquely/flight-finder-api/src/route/job/delete.ts b/uniquely/flight-finder-api/src/route/job/delete.ts index c909a5726..4e40ca3dc 100644 --- a/uniquely/flight-finder-api/src/route/job/delete.ts +++ b/uniquely/flight-finder-api/src/route/job/delete.ts @@ -22,19 +22,26 @@ async function deleteJob(connection: AlwatrConnection): Promise { data: {}, }); } - catch (err) { - if ((err as Error).message === 'document_not_found') { - return connection.reply({ + catch (_err) { + const err = _err as Error; + if (err.message === 'document_not_found') { + connection.reply({ ok: false, statusCode: 404, errorCode: 'document_not_found', }); } - // else - connection.reply({ - ok: false, - statusCode: 500, - errorCode: 'storage_error', - }); + else { + connection.reply({ + ok: false, + statusCode: 500, + errorCode: 'storage_error', + meta: { + name: err.name, + message: err.message, + cause: err.cause, + }, + }); + } } } diff --git a/uniquely/flight-finder-api/src/route/job/get.ts b/uniquely/flight-finder-api/src/route/job/get.ts index 2c7618de6..4de183c54 100644 --- a/uniquely/flight-finder-api/src/route/job/get.ts +++ b/uniquely/flight-finder-api/src/route/job/get.ts @@ -15,12 +15,18 @@ async function getJob(connection: AlwatrConnection): Promise { try { connection.reply(await storageClient.getStorage()); } - catch (err) { - logger.error('getJob', (err as Error).message ?? 'storage_error', (err as Error).stack ?? err); + catch (_err) { + const err = _err as Error; + logger.error('getJob', err.message || 'storage_error', err); connection.reply({ ok: false, statusCode: 500, errorCode: 'storage_error', + meta: { + name: err.name, + message: err.message, + cause: err.cause, + }, }); } } diff --git a/uniquely/flight-finder-api/src/route/job/put.ts b/uniquely/flight-finder-api/src/route/job/put.ts index fe6977f9b..82e965548 100644 --- a/uniquely/flight-finder-api/src/route/job/put.ts +++ b/uniquely/flight-finder-api/src/route/job/put.ts @@ -34,12 +34,18 @@ async function newJob(connection: AlwatrConnection): Promise { data: (await storageClient.set(job)) as unknown as Record, }); } - catch (err) { - logger.error('newJob', (err as Error).message ?? 'storage_error', (err as Error).stack ?? err); + catch (_err) { + const err = _err as Error; + logger.error('newJob', err.message || 'storage_error', err); connection.reply({ ok: false, statusCode: 500, errorCode: 'storage_error', + meta: { + name: err.name, + message: err.message, + cause: err.cause, + }, }); } } From d697e6c4c7d0a4172f4dba9caf6fbd478f79de9c Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 17:27:46 +0330 Subject: [PATCH 2/6] feat: improve accident debugging --- core/fetch/src/fetch.ts | 2 +- core/i18n/src/i18n.ts | 5 ++++- core/nano-server/src/nano-server.ts | 20 +++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/core/fetch/src/fetch.ts b/core/fetch/src/fetch.ts index cf0d5346a..92467583e 100644 --- a/core/fetch/src/fetch.ts +++ b/core/fetch/src/fetch.ts @@ -114,7 +114,7 @@ function _processOptions(options: FetchOptions): Required { options.removeDuplicate ??= 'never'; if (options.cacheStrategy !== 'network_only' && cacheSupported !== true) { - logger.accident('fetch', 'fetch_cache_strategy_ignore', 'Cache storage not support in this browser', { + logger.incident('fetch', 'fetch_cache_strategy_ignore', 'Cache storage not support in this browser', { cacheSupported, }); options.cacheStrategy = 'network_only'; diff --git a/core/i18n/src/i18n.ts b/core/i18n/src/i18n.ts index 4ef9085a2..1e89be247 100644 --- a/core/i18n/src/i18n.ts +++ b/core/i18n/src/i18n.ts @@ -204,7 +204,10 @@ function localize(key?: string | null): string | null { const localized = l10n.resource[key]; if (localized == null) { - logger.accident('localize', 'l10n_key_not_found', 'Key not defined in the localization resource', {key}); + logger.accident('localize', 'l10n_key_not_found', 'Key not defined in the localization resource', { + key, + local: l10n.resource?._code, + }); return `{${key}}`; } diff --git a/core/nano-server/src/nano-server.ts b/core/nano-server/src/nano-server.ts index e10f9d0ff..309ecc47a 100644 --- a/core/nano-server/src/nano-server.ts +++ b/core/nano-server/src/nano-server.ts @@ -165,13 +165,8 @@ export class AlwatrNanoServer { } protected _errorListener(err: NodeJS.ErrnoException): void { - this._logger.accident('server.onError', 'http_server_catch_error', 'HTTP server catch an error', { - errCode: err.code, - errMessage: err.message, - }); - if (err.code === 'EADDRINUSE') { - this._logger.logOther('Address in use, retrying...'); + this._logger.incident('server.onError', 'address_in_use', 'Address in use, retrying...', err); setTimeout(() => { this.httpServer.close(); this.httpServer.listen(this._config.port, this._config.host, () => { @@ -179,6 +174,9 @@ export class AlwatrNanoServer { }); }, 2000); } + else { + this._logger.error('server.onError', 'http_server_catch_error', err.message || 'HTTP server catch an error', err); + } } protected _clientErrorListener(err: NodeJS.ErrnoException, socket: Duplex): void { @@ -331,8 +329,9 @@ export class AlwatrConnection { this._logger.logMethodArgs('reply', {ok: content.ok, statusCode: content.statusCode}); if (this.serverResponse.headersSent) { - this._logger.accident('reply', 'http_header_sent', 'Response headers already sent'); - return; + this._logger.error('reply', 'http_header_sent', 'Response headers already sent'); + if (content.ok === false) return; // prevent loop. + throw new Error('http_header_sent'); } let buffer: Buffer; @@ -399,11 +398,6 @@ export class AlwatrConnection { * ``` */ async getBody(): Promise { - // method must be POST or PUT - if (!(this.method === 'POST' || this.method === 'PUT' || this.method === 'PATCH')) { - return null; - } - let body = ''; this.incomingMessage.on('data', (chunk: unknown) => { From 3e98bd926a495c13d476f2f1cfb9e546a059d4d8 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 21:48:31 +0330 Subject: [PATCH 3/6] fix(fetch): fetch_failed error message --- core/fetch/src/fetch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/fetch/src/fetch.ts b/core/fetch/src/fetch.ts index 92467583e..26c72288d 100644 --- a/core/fetch/src/fetch.ts +++ b/core/fetch/src/fetch.ts @@ -37,8 +37,8 @@ export async function serviceRequest, TMeta = Re response = await fetch(options); } catch (err) { - logger.error('serviceRequest', 'fetch_failed', err, options); - throw new Error('fetch_failed'); + logger.error('serviceRequest', (err as Error).message || 'fetch_failed', err, options); + throw new Error((err as Error).message || 'fetch_failed'); } let responseText: string; From 02639a22a3de3a8456f6b6f03fee19a238856f42 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 22:41:01 +0330 Subject: [PATCH 4/6] refactor(fetch): throw original error --- core/fetch/src/fetch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/fetch/src/fetch.ts b/core/fetch/src/fetch.ts index 26c72288d..4e09d8adc 100644 --- a/core/fetch/src/fetch.ts +++ b/core/fetch/src/fetch.ts @@ -38,7 +38,7 @@ export async function serviceRequest, TMeta = Re } catch (err) { logger.error('serviceRequest', (err as Error).message || 'fetch_failed', err, options); - throw new Error((err as Error).message || 'fetch_failed'); + throw err; } let responseText: string; @@ -49,7 +49,7 @@ export async function serviceRequest, TMeta = Re logger.error('serviceRequest', 'invalid_response', err, { response, }); - throw new Error('invalid_response'); + throw err; } let responseJson: AlwatrServiceResponse; @@ -58,7 +58,7 @@ export async function serviceRequest, TMeta = Re } catch (err) { logger.error('serviceRequest', 'invalid_json', err, {responseText}); - throw new Error('invalid_json'); + throw err; } if (responseJson.ok !== true) { From 5814af2ceeac6e2175c4ab924e4b40cef765072c Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 22:41:22 +0330 Subject: [PATCH 5/6] feat(nano-server): clear debug info from client for security reasons. --- core/nano-server/src/nano-server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/nano-server/src/nano-server.ts b/core/nano-server/src/nano-server.ts index 309ecc47a..f58c8baab 100644 --- a/core/nano-server/src/nano-server.ts +++ b/core/nano-server/src/nano-server.ts @@ -334,6 +334,11 @@ export class AlwatrConnection { throw new Error('http_header_sent'); } + if (!this._logger.debug && !content.ok && content.meta) { + // clear debug info from client for security reasons. + delete content.meta; + } + let buffer: Buffer; try { From 1c3d7a19b4ac49605654d9aa1936336fff8f56cd Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Sun, 18 Dec 2022 23:49:03 +0330 Subject: [PATCH 6/6] refactor(comment): rollback patch --- services/comment/src/route/patch.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/services/comment/src/route/patch.ts b/services/comment/src/route/patch.ts index 83fb7137c..b18c7890d 100644 --- a/services/comment/src/route/patch.ts +++ b/services/comment/src/route/patch.ts @@ -27,12 +27,9 @@ async function setComment(connection: AlwatrConnection): Promise { // } try { - const comment = await storageClient.set(bodyJson, params.storage); - logger.logProperty('comment', comment); - connection.reply({ ok: true, - data: comment, + data: await storageClient.set(bodyJson, params.storage), }); } catch (_err) {