-
Notifications
You must be signed in to change notification settings - Fork 823
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
Fix a background sync reply bug #2014
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin8.9KB gzip'ed (59% of limit) |
After upgrading to version 4.3, we are facing a new issue (that we did not have before) which is apparently related to the new cloning mechanism of replayed requests. Here is the encountered error:
Can this be a direct consequence of commit f165ca0 ? For the sake of completeness, here is the request: const httpOptions = {
headers: new HttpHeaders(
{'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic ******'),
}),
withCredentials: true,
};
const targetUrl = `${touringUrl}/tours/${tourId}/assignments/${agentId}`;
return this.http.put<TourAssignment[]>(targetUrl, null, httpOptions).pipe(
catchError(this.handleError)
); and the applied WB strategy: const queueUpload = new workbox.backgroundSync.Queue('tp-upload-v1', {
maxRetentionTime: Infinity
});
const bgUpload = new workbox.backgroundSync.Plugin(queueUpload);
workbox.routing.registerRoute(
new RegExp('.*/api/v1/touring/.*'),
new workbox.strategies.NetworkOnly({
fetchOptions: {
credentials: 'include',
},
plugins: [bgUpload]
}),
'PUT'
); |
@bligny it's not clear to me where the code is running, as I'm not familiar with the APIs being used. Is that server-side code running in node?
One thing that might be the problem is you're creating both a Try this (which just creates a const queuePlugin = new workbox.backgroundSync.Plugin('tp-upload-v1', {
maxRetentionTime: Infinity
});
workbox.routing.registerRoute(
new RegExp('.*/api/v1/touring/.*'),
new workbox.strategies.NetworkOnly({
fetchOptions: {
credentials: 'include',
},
plugins: [queuePlugin]
}),
'PUT'
); |
@philipwalton thx for spotting the mistake in my code. |
@philipwalton |
Thanks, that seems like a reasonable feature request. |
R: @jeffposnick
Fixes #1984
The issue in #1984 was the request wasn't being cloned in the re-
fetch()
attempt, which in some cases (depending on the request method and body) was causes issues when attempting to clone it later when re-adding it to the queue.This PR fixes the issue and updates the tests to manually read the request when re-fetching to ensure this kind of thing would be caught in the future.