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

* fix logging bug

* Update Provider.js
This commit is contained in:
Mikael Finstad 2023-11-21 19:10:40 +09:00 committed by GitHub
parent a67f0ffdf2
commit 9699e58b5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,7 +111,17 @@ 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)
let jsonData = ''
try {
// TODO improve our uppy logger so that it can take an arbitrary number of arguments,
// each either objects, errors or strings,
// then we dont have to manually do these things like json stringify when logging.
// the logger should never throw an error.
jsonData = JSON.stringify(e.data)
} catch (err) {
// in case JSON.stringify fails (ignored)
}
this.uppy.log(`ignoring event from unknown source ${jsonData}`, 'warning')
return
}