From a0cb3185842792304a3886d17d740249861db0ed Mon Sep 17 00:00:00 2001 From: zcf0508 Date: Wed, 21 May 2025 16:27:48 +0800 Subject: [PATCH 1/2] feat: prevent crashes caused by JSON parsing errors --- src/caddy/index.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/caddy/index.ts b/src/caddy/index.ts index b9e1627..47b0eed 100644 --- a/src/caddy/index.ts +++ b/src/caddy/index.ts @@ -324,18 +324,22 @@ ${target.split(':')[0]}${https ? '' : ':80'} { // caddy log // eslint-disable-next-line no-console showCaddyLog && line && console.info(line) - if (line.includes('Error:') || (line && JSON.parse(line).level === 'error')) { - if (line.includes('parsing caddyfile tokens')) { - consola.error('Caddyfile syntax error, please contact the author:\n', `${this.caddyfile}\n\n${line}\n`) - await this.baseCleanup() - process.exit() - } - else { - consola.error(`${line}\n`) - // child.kill() - return reject(line) + try { + if (line.includes('Error:') || (line && JSON.parse(line).level === 'error')) { + if (line.includes('parsing caddyfile tokens')) { + consola.error('Caddyfile syntax error, please contact the author:\n', `${this.caddyfile}\n\n${line}\n`) + await this.baseCleanup() + process.exit() + } + else { + consola.error(`${line}\n`) + // child.kill() + return reject(line) + } } } + catch {} + if (line.includes('config file changed')) consola.success('Detect added a new reverse proxy config, restarted.\n') From f7d0055b4ff1c8fb33bb4a3fef46811b87bb5aaa Mon Sep 17 00:00:00 2001 From: zcf0508 Date: Wed, 21 May 2025 16:38:35 +0800 Subject: [PATCH 2/2] chore: release v2.0.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79d1607..9fbc57f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unplugin-https-reverse-proxy", "type": "module", - "version": "2.0.1", + "version": "2.0.2", "description": "", "license": "MIT", "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme",