vikejs / vike-react

🔨 React integration for Vike
https://vike.dev/vike-react
MIT License
94 stars 15 forks source link

vike-react-query withFallback error prop does not include error properties #101

Closed Alduino closed 5 months ago

Alduino commented 5 months ago

Using vike-react-query (v0.0.4), I've noticed that no errors caught by withFallback's error boundary seem to have any of their standard properties, other than message.

For example:

withFallback(
    () => {
        useSuspenseQuery({
            queryKey: ["test"],
            queryFn() {
                throw new Error("Test error!", {
                    cause: new Error("Another one!")
                });
            }
        });
        return null;
    },
    {
        Error({error}) {
            console.log("ERROR LOG:", error);
            return null;
        }
    }
);

I would have expected this code to log an object with name, message, cause, and stack properties, but it only has message.

As far as I can tell, the cause of this is because Error keys are not enumerable, so they are ignored in the Object.assign call that creates the error prop. Trying this directly in the console does the same thing - Object.assign({message: "test"}, new Error("Test!")) returns {message: "test"}.

nitedani commented 5 months ago

Thank you for reporting the issue!

Fix pre-relased as 0.0.4-commit-7a99687

Alduino commented 5 months ago

Thank you for fixing that so quick! Though, it seems the prerelease hasn't gone out to npm?

nitedani commented 5 months ago

My mistake, published it now.