Comments (7)
I think it's expected behavior of react error boundaries that they won't catch errors in async code – my understanding is that the error needs to happen in the React tree's render stack to catch it.
Here's a repro (I deleted random info in the GLB file to simulate a bad network request)
https://codesandbox.io/p/sandbox/dazzling-lederberg-8dhfcv
You'll see that even though there's an error boundary, the error thrown by useGLTF
is causing the entire app to crash.
Seems odd that I'd be the first person to find this so I could definitely be missing something... although you might only notice
if you're paying careful attention within large amounts of traffic.
from react-three-fiber.
Okay, we're probably not catching errors thrown from promises. We don't intend for this tricky behavior to be possible.
from react-three-fiber.
Here is my workaround code for now in case it is helpful for folks.
Note: this isn't idiomatic React and probably causes other problems in some situations.
export const BambooBox = () => {
try {
const { nodes, materials } = useGLTF(path);
return (
<mesh
geometry={nodes.Cylinder.geometry}
material={materials.Bamboo}
/>
);
} catch (err) {
return <Fallback />;
}
};
from react-three-fiber.
I'd need to see an example, but this sounds like a React bug which should be taken upstream. You can harden your workaround by continuing to throw a promise if passed to err
so Suspense works as expected.
from react-three-fiber.
The way it happened in the wild was a valid URL but a network error on Poki (so not a 404 but not the full file returned either) happening once every thousand users or so.
from react-three-fiber.
Related Issues (20)
- Documentation update to use "three/addons" rather than "three/examples" HOT 3
- GLTF is not solid?
- Typescript Error: 'Canvas' cannot be used as a JSX component. HOT 6
- Support translation of geometries HOT 2
- Support some type of `addEventListener` on native `Canvas` HOT 1
- Any guide on how to migrate to the new ThreeJS lighting model? HOT 2
- Cannot read property 'GLView' at react-native
- THREE.WebGLRenderer context lost when I route to another page HOT 1
- Allow pass custom store by props
- How to animate material during rendering
- How to render text on top of material from list of materials? HOT 1
- Invalidate is not behaving as expected HOT 5
- Can we modify useLoader to accept an empty string or null? HOT 1
- XRFrame type resolving incorrectly HOT 2
- Error loading OBJ model in React Native HOT 2
- Help: TypeError in is.equ HOT 4
- Primitive with children mounting / unmounting + documentation HOT 4
- This sandbox doesn't work HOT 1
- Canvas eventHandler: onWebGLContextLost, onWebGLContextRestored HOT 2
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 react-three-fiber.