-
-
Notifications
You must be signed in to change notification settings - Fork 428
better error: show a warning/error when server-preloaded data can't be transmitted to the client #1304
better error: show a warning/error when server-preloaded data can't be transmitted to the client #1304
Conversation
…d data that can't be transmitted to the client
This looks good. Is there a good way to add a test for this? |
Sure; see the latest commit. |
I believe the original intention of this behavior was that, if there were no preload data sent from the server to the client (for example, if it could not be serialized), the client-side preload would be also be run to try to re-create it. I don't think this should be an outright error. Also sort of adjacent: #843. |
Does that mean the most preferred behavior was in commit 427a6bc and the ones added since then should be dropped from this PR? (In which case, this stops being a breaking change) |
How about if we error out with a hard fail if we're in development mode, but allow the client to re-render over the top of it in production mode? That would make it easier to notice something's wrong in development, but not error unless necessary in production |
Also, we made a very similar change in 0.27.14 in #719. Perhaps we'd want it to do the same? |
Having this be an error, even in dev mode, seems to indicate that we're telling the user they're doing something objectively wrong that we don't want to support, but that, for some technical/performance/whatever reason, we don't want to enforce it in production builds. I'm okay with making this a warning, but, again, making this be an error at all (even in dev mode) marks a conscious change in how we're saying this feature should work, and I don't think that change is warranted. It's perfectly possible to have a working (although non-optimal) app that re-runs preload on the client. |
If you wanted to run something only on the client, I'd expect you'd put it in |
I don't think this should be an error, this is a pretty significant breaking change and I don't think any of the arguments in favour are particularly convincing. Certainly not convincing enough to make this change without further discussion on what the behaviour should be. This is the kind of breaking change that could require significant investment from users to fix and offers very little value in exchange. I'd suggest going with a warning for now, if anything. At the very least we need a simple way for users to log these errors to their error reporting system before issuing this change. |
Making this be an error feels to me like a frivolous, puritanical thing for Sapper to do. |
I'm okay with the warning behavior @babichjacob initially proposed if everyone else is. I made a backup of this branch and then rewound it to the initial commit. Let me know if it looks okay now |
As a user I've been very surprised in a bad way by the existing behavior.
It's only after I add a lot more logging that I realize that I'm preloading
twice because I'm accidentally trying to serialize something that can't be
serialized.
By swallowing the failure we put people that are trying to build fast,
efficient services at a meaningful disadvantage. :/
…On Sun, Aug 2, 2020, 17:14 Conduitry ***@***.***> wrote:
preload prevents the component from loading at all (and delays
navigation) until the promises resolve, which onMouint cannot do. IMO
you're not writing code that fails on the server, you're writing code that
returns a value that we can't *serialize* on the server.
Making this be an error feels to me like a frivolous, puritanical thing
for Sapper to do.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1304 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAABZHPVRH6PFDNG2JSPVNTR6X6NTANCNFSM4OQW57OQ>
.
|
Before submitting the PR, please make sure you do the following
preload
), Provide warning if store data cannot be serialized by devalue #447 (resolved issue that never got closed by the way; there is already an error for the same situation with thesession
store)npm run lint
!): There is no way to mock/assert console output inmocha
/assert
without introducing another dependency likesinon
. By the way, there is no longer alint
package script.Tests
npm test
oryarn test
: 1 test was already failing and this doesn't change thatLike was said in #447, if there is data in
preload
's return that cannot be serialized bydevalue
(like a function in my case), the client will not receive a copy. There are no warnings for this (i.e. this is a completely silent failure), which was a source of confusion for me, despite this behavior being documented. (Actually, another PR to specify what it means when serialization fails could be needed since it is not explicitly stated thatpreload
runs again client-side rather than displaying an error page).This pull request introduces an error (where serialization failed and why) + warning (consequences and more information) message combo in the server side console while remaining silent in the client side. This approach was taken to remain backwards compatible and not bother the client with the server's mistakes.
Possible problems or improvements still needed with this:
error
thenwarn
) rather than onedev
session
store's serialization fails, which displays an error page (see 2 lines later in the same file)