From 250a9e605cb885a0372b2f59d98c1228c77f0059 Mon Sep 17 00:00:00 2001 From: maslow Date: Wed, 3 Nov 2021 16:33:53 +0800 Subject: [PATCH] fix(app-service): fix uncaught promise rejected in cloud function, cause that process exit --- docker-compose.yml | 2 +- packages/app-service/package-lock.json | 1 + packages/app-service/package.json | 8 ++++++++ packages/app-service/src/index.ts | 10 +++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5dded408bf..8a324be43f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,7 +58,7 @@ services: ACCOUNT_DEFAULT_APP_QUOTA: 5 APP_SERVICE_DEPLOY_HOST: local-dev.host:8080 # `*.local-dev.host` always resolved to 127.0.0.1, used to local development APP_SERVICE_DEPLOY_URL_SCHEMA: 'http' - # DEBUG_BIND_HOST_APP_PATH: '${PWD}/packages/app-service' + DEBUG_BIND_HOST_APP_PATH: '${PWD}/packages/app-service' command: npx nodemon volumes: - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/packages/app-service/package-lock.json b/packages/app-service/package-lock.json index 40c893bf07..1d2ac80a4b 100644 --- a/packages/app-service/package-lock.json +++ b/packages/app-service/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "app-service", "version": "0.6.5", "dependencies": { "axios": "^0.21.1", diff --git a/packages/app-service/package.json b/packages/app-service/package.json index 7bc419fb8a..0dd583a2e7 100644 --- a/packages/app-service/package.json +++ b/packages/app-service/package.json @@ -54,5 +54,13 @@ "@types/nodemailer": "^6.4.4", "@types/validator": "^13.1.3", "typescript": "^4.2.3" + }, + "nodemonConfig": { + "ignore": [ + "test/*", + "src/*", + "http/*" + ], + "delay": 1000 } } diff --git a/packages/app-service/src/index.ts b/packages/app-service/src/index.ts index 636bf8b054..7dd97ad302 100644 --- a/packages/app-service/src/index.ts +++ b/packages/app-service/src/index.ts @@ -1,7 +1,7 @@ /* * @Author: Maslow * @Date: 2021-07-30 10:30:29 - * @LastEditTime: 2021-11-01 11:37:43 + * @LastEditTime: 2021-11-03 16:28:03 * @Description: */ @@ -26,6 +26,14 @@ server.use(express.urlencoded({ extended: true }) as any) +process.on('unhandledRejection', (reason, promise) => { + logger.error(`Caught unhandledRejection:`, reason, promise) +}) + +process.on('uncaughtException', err => { + logger.error(`Caught uncaughtException:`, err) +}) + /** * Allow CORS by default */