Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure getCallSites return array #129

Merged

Conversation

barakd
Copy link
Contributor

@barakd barakd commented Dec 28, 2021

I encountered a case using ts log version 3.3.0, typescript version 4.5.2 and node v16.13.1
Where on some errors the getCallSiteHelper will return undefined, and not array.
In such cases the logger will explode the whole server due to the slice operation done in LoggerHelper.ts:50
In this minor adjustment I am aligning the helper to respect it's signature, and make sure we always return an array.

/workspaces/usr/packages/package-a/dist/node_modules/.pnpm/tslog@3.3.0/node_modules/tslog/src/LoggerHelper.ts:50
      error == null ? getCallSites(new Error()).slice(1) : getCallSites(error);
                                               ^
TypeError: Cannot read properties of undefined (reading 'slice')
    at Function.getCallSites (/workspaces/usr/packages/package-a/dist/node_modules/.pnpm/tslog@3.3.0/node_modules/tslog/src/LoggerHelper.ts:50:48)

@terehov
Copy link
Contributor

terehov commented Dec 28, 2021

Thank you!

@terehov terehov merged commit c9b2a29 into fullstack-build:master Dec 28, 2021
@terehov
Copy link
Contributor

terehov commented Dec 28, 2021

Here you go :-)

https://github.com/fullstack-build/tslog/releases/tag/v3.3.1

@barakd barakd deleted the ensure-call-sites-return-array branch December 29, 2021 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants