@@ -31,6 +31,7 @@ use crate::{
3131 ExecutorRequest ,
3232 InvokeResponse ,
3333 NodeExecutor ,
34+ ARGS_TOO_LARGE_RESPONSE_MESSAGE ,
3435 EXECUTE_TIMEOUT_RESPONSE_JSON ,
3536 } ,
3637 handle_node_executor_stream,
@@ -252,7 +253,15 @@ impl NodeExecutor for LocalNodeExecutor {
252253 } ,
253254 } ;
254255
255- if !response. status ( ) . is_success ( ) {
256+ if let Err ( e) = response. error_for_status_ref ( ) {
257+ if e. status ( ) == Some ( reqwest:: StatusCode :: PAYLOAD_TOO_LARGE ) {
258+ return Err (
259+ anyhow:: anyhow!( e. without_url( ) ) . context ( ErrorMetadata :: bad_request (
260+ "ArgsTooLarge" ,
261+ ARGS_TOO_LARGE_RESPONSE_MESSAGE ,
262+ ) ) ,
263+ ) ;
264+ }
256265 let error = response. text ( ) . await ?;
257266 anyhow:: bail!( "Node executor server returned error: {}" , error) ;
258267 }
@@ -301,7 +310,10 @@ mod tests {
301310 value:: ConvexValue ,
302311 version:: Version ,
303312 } ;
304- use errors:: ErrorMetadataAnyhowExt ;
313+ use errors:: {
314+ ErrorMetadata ,
315+ ErrorMetadataAnyhowExt ,
316+ } ;
305317 use futures:: FutureExt ;
306318 use isolate:: test_helpers:: TEST_SOURCE ;
307319 use keybroker:: {
@@ -650,6 +662,40 @@ mod tests {
650662 Ok ( ( ) )
651663 }
652664
665+ #[ convex_macro:: prod_rt_test]
666+ async fn test_args_too_large ( rt : ProdRuntime ) -> anyhow:: Result < ( ) > {
667+ let storage = Arc :: new ( LocalDirStorage :: new ( rt. clone ( ) ) ?) ;
668+ let actions = create_actions ( rt) . await ;
669+ let source_package = upload_modules ( storage. clone ( ) , TEST_SOURCE . clone ( ) ) . await ?;
670+
671+ // Create ~6MB of args data, which is too large for Node functions.
672+ let args = create_args ( assert_obj ! (
673+ "message" => "a" . repeat( 6 * 1024 * 1024 )
674+ ) ) ?;
675+ let path_and_args = ValidatedPathAndArgs :: new_for_tests (
676+ "node_actions.js:echoMessage" . parse ( ) ?,
677+ args,
678+ VERSION . clone ( ) ,
679+ ) ;
680+ let error = execute (
681+ & actions,
682+ execute_request ( path_and_args, source_package) ,
683+ empty_source_maps_callback ( ) ,
684+ )
685+ . await
686+ . unwrap_err ( ) ;
687+
688+ assert_eq ! (
689+ & error. to_string( ) ,
690+ "Node actions arguments size is too large. The maximum size is 5 MiB. Reduce the size \
691+ of the arguments or consider using V8 actions instead, which have a 16 MiB limit."
692+ ) ;
693+ let metadata = error. downcast_ref :: < ErrorMetadata > ( ) . unwrap ( ) ;
694+ assert ! ( metadata. is_deterministic_user_error( ) ) ;
695+
696+ Ok ( ( ) )
697+ }
698+
653699 #[ convex_macro:: prod_rt_test]
654700 async fn test_forgot_await ( rt : ProdRuntime ) -> anyhow:: Result < ( ) > {
655701 let storage = Arc :: new ( LocalDirStorage :: new ( rt. clone ( ) ) ?) ;
0 commit comments