Skip to content

Swallowed fetch failure #488

@fredericDelaporte

Description

@fredericDelaporte

The user session fetch method appears to have a "catch all" that swallows all troubles silently, then pretends the session is ready.

const fetch = async () => {
sessionState.value = await useRequestFetch()<UserSession>('/api/_auth/session', {
headers: {
accept: 'application/json',
},
retry: false,
}).catch(() => null)
if (!authReadyState.value) {
authReadyState.value = true
}
}

That is troublesome in case of failure, since the application user code has no way of detecting it, and no way of reporting the trouble.

I have searched the file history and saw it was there since the creation of the file, so, I found no explanation for this in the source. I have also searched issues without finding any about this.

What is the rationale for this implementation?

Should it be changed?

Underlying trouble that caused me to see this: I have implemented a "refresh" of the user session data by calling this fetch periodically (through setTimeout). It is meant for detecting if it has been changed through actions on another tab of the browser. When a fetch failure occurs, it causes the user data to switch to null, causing the Web site to switch to "unauthenticated" mode, while actually, the authentication is still there: reloading entirely the page allows it to switch back to logged in.

More troublesome to me, I have no way to see the fetch has actually failed to diagnose and fix the trouble, or at least, handle some retry logic. (In the browser, in my case, the trouble seems the HTTP request being sometime cancelled, appearing in the browser network pane without any response. No idea what would cause that cancellation.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions