remotestorage/remotestorage.js

remoteStorage error event not returning expected response

murphypetercl opened this issue · 8 comments

Hi guys,
I'm trying to handle auth expiry in an app I'm playing with (i.e. when the widget displays the "App authorization expired or revoked, Renew" message).

I am capturing the error as follows:

remoteStorage.on('error', (err) => {
console.log('Remote storage - error')
console.log(err)
})

Per the documentation https://remotestoragejs.readthedocs.io/en/v1.2.3/js-api/remotestorage.html I expected to see something like:

// {
// name: "Unauthorized",
// message: "App authorization expired or revoked.",
// stack: "Error↵ at new a.Unauthorized (vendor.js:65710:41870)"
// }

But what I actually get is this:

image

Only tested with dropbox so far. Thanks

This could be a bug with the Dropbox back-end. Could you test this with the normal RS back-end as well perhaps?

Also, is the app using rs.js 1.2.3 or 2.0.0-beta.0 (or yet another version)?

Thanks for the quick response. I'll try with 5apps. Is there a way to set a short expiry with 5apps do you know? The shortest option I can see seems to be 1 day. With Dropbox it is 4 hours.

I'm using the 2.0.0 beta.

Yes, I think 1 day is the shortest option.

Edit: you could trigger 403s by editing the auth token in your browser's localStorage for example...

Another way to trigger the error faster is to revoke the token in the 5apps interface.

Another way to trigger the error faster is to revoke the token in the 5apps interface.

OMG, of course! Much easier and quicker.

Cool thanks, I was able to simulate it that way. Getting the same error with 5apps though:

image

Hmm, at first glance I cannot see how this could break. The connect widget, which is tested with the latest beta, uses the error's name property, and there's also a unit test for it in the WireClient test suite in this repo.

Are you sure it's not a problem with the logging somehow? What does err.name or err.message return in your code?

Cool that has worked.

image

image

I guess the console output of the err object just threw me off. Maybe an idea to tweak the documentation to clarify how to use it.

This is a great library btw - really liking it.