Skip to content

Commit

Permalink
fix(qwik-city): wait until action fully complete before resolving its… (
Browse files Browse the repository at this point in the history
#5190)

fix(qwik-city): wait until action fully complete before resolving its promise

Fix #5177
  • Loading branch information
mhevery committed Sep 18, 2023
1 parent af0623e commit b5cf6d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/qwik-city/runtime/src/use-endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const loadClientData = async (
dispatchPrefetchEvent({
links: [pagePathname],
});
let resolveFn: () => void | undefined;

if (!qData) {
const options = getFetchOptions(action);
Expand Down Expand Up @@ -49,7 +50,9 @@ export const loadClientData = async (
location.href = clientData.redirect;
} else if (action) {
const actionData = clientData.loaders[action.id];
action.resolve!({ status: rsp.status, result: actionData });
resolveFn = () => {
action.resolve!({ status: rsp.status, result: actionData });
};
}
return clientData;
});
Expand All @@ -68,6 +71,7 @@ export const loadClientData = async (
if (!v) {
CLIENT_DATA_CACHE.delete(clientDataPath);
}
resolveFn && resolveFn();
return v;
});
};
Expand Down

0 comments on commit b5cf6d1

Please sign in to comment.