From 0eff67d12ad48931fa6cc43861b8b2ed91a52e2c Mon Sep 17 00:00:00 2001 From: AgnesToulet <35176601+AgnesToulet@users.noreply.github.com> Date: Tue, 17 Dec 2024 20:42:24 +0100 Subject: [PATCH] fix plugin mode --- src/plugin/v2/grpc_plugin.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/plugin/v2/grpc_plugin.ts b/src/plugin/v2/grpc_plugin.ts index 9ba10da..97f2ab5 100644 --- a/src/plugin/v2/grpc_plugin.ts +++ b/src/plugin/v2/grpc_plugin.ts @@ -100,7 +100,9 @@ class PluginGRPCServer { } async render(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData) { - const { signal } = new AbortController(); + const abortController = new AbortController(); + const { signal } = abortController; + const req = call.request; const headers: HTTPHeaders = {}; @@ -140,7 +142,12 @@ class PluginGRPCServer { }; this.log.debug('Render request received', 'url', options.url); + call.on('cancelled', (err) => { + this.log.debug('Connection closed', 'url', options.url, 'error', err); + abortController.abort(); + }); let errStr = ''; + try { await this.browser.render(options, signal); } catch (err) { @@ -151,7 +158,8 @@ class PluginGRPCServer { } async renderCsv(call: grpc.ServerUnaryCall, callback: grpc.sendUnaryData) { - const { signal } = new AbortController(); + const abortController = new AbortController(); + const { signal } = abortController; const req = call.request; const headers: HTTPHeaders = {}; @@ -188,6 +196,11 @@ class PluginGRPCServer { }; this.log.debug('Render request received', 'url', options.url); + call.on('cancelled', (err) => { + this.log.debug('Connection closed', 'url', options.url, 'error', err); + abortController.abort(); + }); + let errStr = ''; let fileName = ''; try {