Skip to content

Commit

Permalink
Fix SPA mode when single fetch is enabled (#9063)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Mar 19, 2024
1 parent adc11ff commit 861d948
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/remix-dev/cli/commands.ts
Expand Up @@ -303,7 +303,8 @@ export async function generateEntry(
let defaultEntryClient = path.resolve(defaultsDirectory, "entry.client.tsx");
let defaultEntryServer = path.resolve(
defaultsDirectory,
ctx?.remixConfig.ssr === false
ctx?.remixConfig.ssr === false &&
ctx?.remixConfig.future.unstable_singleFetch !== true
? `entry.server.spa.tsx`
: `entry.server.${serverRuntime}.tsx`
);
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/config.ts
Expand Up @@ -469,7 +469,7 @@ export async function resolveConfig(
let pkgJson = await PackageJson.load(rootDirectory);
let deps = pkgJson.content.dependencies ?? {};

if (isSpaMode) {
if (isSpaMode && appConfig.future?.unstable_singleFetch != true) {
// This is a super-simple default since we don't need streaming in SPA Mode.
// We can include this in a remix-spa template, but right now `npx remix reveal`
// will still expose the streaming template since that command doesn't have
Expand Down
5 changes: 4 additions & 1 deletion packages/remix-dev/config/defaults/entry.server.node.tsx
Expand Up @@ -15,7 +15,10 @@ export default function handleRequest(
remixContext: EntryContext,
loadContext: AppLoadContext
) {
return isBotRequest(request.headers.get("user-agent"))
let prohibitOutOfOrderStreaming =
isBotRequest(request.headers.get("user-agent")) || remixContext.isSpaMode;

return prohibitOutOfOrderStreaming
? handleBotRequest(
request,
responseStatusCode,
Expand Down

0 comments on commit 861d948

Please sign in to comment.