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

@uppy/companion-client: fix log type error #4766

Merged
merged 2 commits into from
Nov 21, 2023
Merged

@uppy/companion-client: fix log type error #4766

merged 2 commits into from
Nov 21, 2023

Conversation

mifi
Copy link
Contributor

@mifi mifi commented Oct 25, 2023

fixes this.uppy.log.warn is not a function

@@ -111,7 +111,7 @@ export default class Provider extends RequestClient {
const authWindow = window.open(link, '_blank')
const handleToken = (e) => {
if (e.source !== authWindow) {
this.uppy.log.warn('ignoring event from unknown source', e)
this.uppy.log(`ignoring event from unknown source ${JSON.stringify(e.data)}`, 'warning')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch for stringify not needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe yea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if e.data might not be valid, we should check that rather than rely on try/catch. But maybe it's always valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea maybe it’s better that it crashes if the data is invalid? Then we can fix the bug when we know what to fix

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That also but in this case I meant a type check if we are doubting the validity: if (e.data).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think that’s going to help at all, because most things that are falsy will not cause JSON.stringify to fail afaik. What could make it fail however is circular references or BigInts anywhere in the tree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw we should really improve our uppy logger so that it can take an arbitrary number of arguments, each either objects, errors or strings. Then we don’t have to manually do these things like json stringify when logging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added a try/catch just to be sure, because IMO a log statement should never throw an error

@Murderlon Murderlon changed the title fix logging bug @uppy/companion-client: fix log type error Oct 25, 2023
@mifi
Copy link
Contributor Author

mifi commented Nov 6, 2023

let's merge?

@AndreyMarchuk
Copy link

+1, experiencing the same issue

@mifi mifi requested a review from arturi November 21, 2023 08:09
@Murderlon Murderlon merged commit 9699e58 into main Nov 21, 2023
14 checks passed
@Murderlon Murderlon deleted the fix-logging-bug branch November 21, 2023 10:10
@github-actions github-actions bot mentioned this pull request Nov 24, 2023
github-actions bot added a commit that referenced this pull request Nov 24, 2023
| Package                | Version | Package                | Version |
| ---------------------- | ------- | ---------------------- | ------- |
| @uppy/companion-client |   3.6.1 | @uppy/store-default    |   3.1.0 |
| @uppy/locales          |   3.5.0 | uppy                   |  3.20.0 |

- meta: uppy CDN: Export UIPlugin and BasePlugin (Artur Paikin / #4774)
- @uppy/locales: Add missing translations to de_DE (Leonhard Melzer / #4800)
- @uppy/store-default: refactor to typescript (Antoine du Hamel / #4785)
- meta: improve js2ts script (Antoine du Hamel / #4786)
- @uppy/companion-client: fix log type error (Mikael Finstad / #4766)
- @uppy/companion-client: revert breaking change (Antoine du Hamel / #4801)
- @uppy/locales: use TypeScript for source files (Antoine du Hamel / #4779)
- meta: migrate AWS SDK v2 to v3 in `bin/uploadcdn` (Trivikram Kamat / #4776)
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.

4 participants