From 7b877308a4c17fc1d822e5181c5cdda51317dc6f Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Tue, 24 Oct 2023 08:00:49 -0500 Subject: [PATCH] Fixes #140 Unable to configure localStorage polyfill when running under AWS Lambda functions --- packages/node/src/NodeExceptionlessClient.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/node/src/NodeExceptionlessClient.ts b/packages/node/src/NodeExceptionlessClient.ts index f4989521..11e46b19 100644 --- a/packages/node/src/NodeExceptionlessClient.ts +++ b/packages/node/src/NodeExceptionlessClient.ts @@ -19,9 +19,13 @@ export class NodeExceptionlessClient extends ExceptionlessClient { const config = this.config; if (configurationOrApiKey && !this._initialized) { - const storage = new LocalStorage(undefined, new LocalStoragePolyfill(process.cwd() + '/.exceptionless')); - config.useLocalStorage = () => storage; - config.services.storage = storage; + try { + const storage = new LocalStorage(undefined, new LocalStoragePolyfill(process.cwd() + '/.exceptionless')); + config.useLocalStorage = () => storage; + config.services.storage = storage; + } catch (ex) { + this.config.services.log.info(`Error configuring localStorage polyfill: ${ex instanceof Error ? ex.message : ex + ''}`); + } config.addPlugin(new NodeEnvironmentInfoPlugin()); config.addPlugin(new NodeGlobalHandlerPlugin());