Second call to same server action is 'disappearing' #70888
Unanswered
cefn
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to explain a case where server actions are just disappearing and never being received by the Next server. This is with the app router and
next@14.2.14
I have logging breakpoints:
I was surprised to find that the client breakpoint logs the two calls (expected to be made), but the server breakpoint only logs one call (apparently not ever receiving the second call from the client). The first client call returns data successfully. The second client call hangs indefinitely without the Promise ever resolving.
Debug logging with timestamps
# Client debug log launch.ts:129 indexPostings sent 1728261488301 launch.ts:129 indexPostings sent 1728261488305
Background
These are very rapid duplicate calls in succession. This is because NextJS ships by default with strict mode, and this causes useEffects to be called and unloaded then called again during development.
If I turn off strict mode in development, my application seems fully-functional with repeated calls to the
indexPostingsAction
arising from interactions with the app, and completing successfully (although not in such rapid succession).I can't see how it relates to my code, since I have breakpoints at the layer in which it enters to NextJS magic and where it exits on the other side. I don't think I can influence the success of these calls as none of my code is running between these client-side and server-side breakpoints.
Is this somehow normal? Have I misunderstood how serverActions should have their cache configured? I'm struggling to know how never-resolving could possibly be an expected behaviour (although maybe with caching sending the previous result twice might make sense).
Is this a race condition in NextJS server actions?
Code samples
On the client-side the surrounding code that calls
indexPostingsAction
looks like this, with all payloads to the action being simple and serializable...Beta Was this translation helpful? Give feedback.
All reactions