Comments (11)
The fix for this is out in 1.15.0-pre.1
if anyone wants to give that a spin. We should have a stable 1.15.0
out soon as well.
from blues-stack.
@machour I would encourage you to reopen – If you look at the repo (and my instructions above), I'm awaiting the data in the loader, so it should be "instantly" available.
I did find the issue – it's the --bundle
flag on the build:server
script. If you remove it, everything works as expected.
from blues-stack.
🤦🏼♂️ sorry @justinwaite, reopened.
from blues-stack.
Any new info regarding this? I'm running into this as well but removing --bundle
is not an option for me.
from blues-stack.
This looks to be due to a failing instanceof
check across a CJS/ESM boundary when using --bundle
. We'll get a fix added for this but in the meantime if you'd like to get past it via patch-package
you just need to replace the single check in @remix-run/router
:
// before
if (result instanceof DeferredData) {
// after
if (result &&
typeof result === "object" &&
typeof result.data === "object" &&
typeof result.subscribe === "function" &&
typeof result.cancel === "function" &&
typeof result.resolveData === "function") {
You should patch this in all 3 build files to be safe:
@remix-run/router/dist/router.js
@remix-run/router/dist/router.cjs.js
@remix-run/router/dist/router.umd.js
from blues-stack.
Repro repo: https://github.com/justinwaite/blues-stack-defer
from blues-stack.
switching from json to defer is not enough, you have to wrap the deferred data in <Await />
See our guide on streaming: https://remix.run/docs/en/v1/guides/streaming#the-solution
from blues-stack.
If you want, feel free to remove await
in the loader and add Suspense
and Await
in the component. You just don't need to go that far to see the error. The result is the same.
from blues-stack.
@justinwaite @JDouven Does it work with the default Remix template?
https://github.com/remix-run/remix/tree/main/templates/remix
from blues-stack.
@MichaelDeBoey Yes, that works. In my case I serve the app with express instead of remix-serve.
I used the following code:
import { defer } from '@remix-run/node';
import { Await, useLoaderData } from '@remix-run/react';
import { Suspense } from 'react';
export async function loader() {
const testPromise = new Promise<string>((resolve) => {
setTimeout(() => {
resolve('Hello with a delay!');
}, 3000);
});
return defer({
instantly: 'foo',
testPromise,
});
}
export default function Index() {
const data = useLoaderData<typeof loader>();
return (
<div style={{ fontFamily: 'system-ui, sans-serif', lineHeight: '1.4' }}>
<h1>Welcome to Remix</h1>
<h2>Instant data:</h2>
<pre>{data.instantly}</pre>
<h2>Streamed data:</h2>
<Suspense fallback={<p>Suspense fallback</p>}>
<Await
resolve={data.testPromise}
errorElement={<p>Await errorElement</p>}
>
{(testPromise) => <pre>{testPromise}</pre>}
</Await>
</Suspense>
</div>
);
}
So I used the express template, and that works too. Then I changed the following to make it more closely match the relevant parts of blues-stack:
- Rename server.js to server.ts and fix the imports (and npm install missing types)
- Update package.json to:
"scripts": {
"build": "remix build",
"build:server": "esbuild --platform=node --format=cjs ./server.ts --outdir=build --bundle",
"dev": "run-p dev:*",
"dev:remix": "remix watch",
"dev:build": "cross-env NODE_ENV=development npm run build:server -- --watch",
"dev:server": "cross-env NODE_ENV=development node --inspect --require ./node_modules/dotenv/config ./build/server.js",
}
(inspired by the blues-stack package.json)
When I now run npm run dev
my example stops working. The frontend stops receiving loader data completely. Neither the 'instant' data nor the streamed data is visible.
Also in this small example, removing --bundle
from the build:server
script is a workaround. However as I said, that is not an option in the larger app I want to use this in.
Let me know if you need more info.
from blues-stack.
@brophdawg11 I tried this and I can confirm this fixes the issue! Thanks!
from blues-stack.
Related Issues (20)
- Wrong http status code (500) returned instead of 404 or any response thrown from a loader. HOT 9
- Hydration error: Initial UI does not match server HOT 3
- When Using Express Adapter Throwing Responses will break the app HOT 1
- great repro
- Race condition in npm run dev HOT 5
- Base Repo OOMs on Fly.io HOT 7
- Fly.io -> Error: Can't reach database server HOT 7
- `npm run typecheck` fails on fresh project HOT 7
- blues-stack 2.0.0-pre.5 - LiveReload is not working HOT 2
- v2_dev leaves one node process behind after shutdown HOT 1
- Scripts variant in README to support the Yarn inclined
- Deployment issue. Node version >18 needed
- Update server.ts to watch version.txt
- Error when trying to run the docker image HOT 3
- Latest server.js code breaks HDR HOT 1
- Some URLs in the `/build` path were 404 not found after making changes in development mode HOT 1
- Vite support
- Build failed while running npm run build on blues stack HOT 2
- Install an esm package dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blues-stack.