22
22
#include " spawn_sync.h"
23
23
#include " debug_utils-inl.h"
24
24
#include " env-inl.h"
25
+ #include " node_errors.h"
25
26
#include " node_external_reference.h"
26
27
#include " node_internals.h"
27
28
#include " string_bytes.h"
@@ -185,15 +186,17 @@ void SyncProcessStdioPipe::Close() {
185
186
lifecycle_ = kClosing ;
186
187
}
187
188
188
-
189
- Local<Object> SyncProcessStdioPipe::GetOutputAsBuffer ( Environment* env) const {
189
+ MaybeLocal<Object> SyncProcessStdioPipe::GetOutputAsBuffer (
190
+ Environment* env) const {
190
191
size_t length = OutputLength ();
191
- Local<Object> js_buffer = Buffer::New (env, length).ToLocalChecked ();
192
+ Local<Object> js_buffer;
193
+ if (!Buffer::New (env, length).ToLocal (&js_buffer)) {
194
+ return MaybeLocal<Object>();
195
+ }
192
196
CopyOutput (Buffer::Data (js_buffer));
193
197
return js_buffer;
194
198
}
195
199
196
-
197
200
bool SyncProcessStdioPipe::readable () const {
198
201
return readable_;
199
202
}
@@ -446,7 +449,10 @@ MaybeLocal<Object> SyncProcessRunner::Run(Local<Value> options) {
446
449
CloseHandlesAndDeleteLoop ();
447
450
if (r.IsNothing ()) return MaybeLocal<Object>();
448
451
449
- Local<Object> result = BuildResultObject ();
452
+ Local<Object> result;
453
+ if (!BuildResultObject ().ToLocal (&result)) {
454
+ return MaybeLocal<Object>();
455
+ }
450
456
451
457
return scope.Escape (result);
452
458
}
@@ -679,58 +685,80 @@ void SyncProcessRunner::SetPipeError(int pipe_error) {
679
685
pipe_error_ = pipe_error;
680
686
}
681
687
682
-
683
- Local<Object> SyncProcessRunner::BuildResultObject () {
688
+ MaybeLocal<Object> SyncProcessRunner::BuildResultObject () {
684
689
EscapableHandleScope scope (env ()->isolate ());
685
690
Local<Context> context = env ()->context ();
686
691
687
692
Local<Object> js_result = Object::New (env ()->isolate ());
688
693
689
- if (GetError () != 0 ) {
690
- js_result->Set (context, env ()->error_string (),
691
- Integer::New (env ()->isolate (), GetError ())).Check ();
694
+ if (GetError () != 0 && js_result
695
+ ->Set (context,
696
+ env ()->error_string (),
697
+ Integer::New (env ()->isolate (), GetError ()))
698
+ .IsNothing ()) {
699
+ return MaybeLocal<Object>();
692
700
}
693
701
694
702
if (exit_status_ >= 0 ) {
695
703
if (term_signal_ > 0 ) {
696
- js_result->Set (context, env ()->status_string (),
697
- Null (env ()->isolate ())).Check ();
698
- } else {
699
- js_result->Set (context, env ()->status_string (),
700
- Number::New (env ()->isolate (),
701
- static_cast <double >(exit_status_))).Check ();
704
+ if (js_result
705
+ ->Set (context, env ()->status_string (), Null (env ()->isolate ()))
706
+ .IsNothing ()) {
707
+ return MaybeLocal<Object>();
708
+ }
709
+ } else if (js_result
710
+ ->Set (context,
711
+ env ()->status_string (),
712
+ Number::New (env ()->isolate (),
713
+ static_cast <double >(exit_status_)))
714
+ .IsNothing ()) {
715
+ return MaybeLocal<Object>();
702
716
}
703
- } else {
704
717
// If exit_status_ < 0 the process was never started because of some error.
705
- js_result->Set (context, env ()->status_string (),
706
- Null (env ()->isolate ())).Check ();
718
+ } else if (js_result
719
+ ->Set (context, env ()->status_string (), Null (env ()->isolate ()))
720
+ .IsNothing ()) {
721
+ return MaybeLocal<Object>();
707
722
}
708
723
709
- if (term_signal_ > 0 )
710
- js_result
711
- ->Set (context,
712
- env ()->signal_string (),
713
- OneByteString (env ()->isolate (), signo_string (term_signal_)))
714
- .Check ();
715
- else
716
- js_result->Set (context, env ()->signal_string (),
717
- Null (env ()->isolate ())).Check ();
724
+ if (term_signal_ > 0 ) {
725
+ if (js_result
726
+ ->Set (context,
727
+ env ()->signal_string (),
728
+ OneByteString (env ()->isolate (), signo_string (term_signal_)))
729
+ .IsNothing ()) {
730
+ return MaybeLocal<Object>();
731
+ }
732
+ } else if (js_result
733
+ ->Set (context, env ()->signal_string (), Null (env ()->isolate ()))
734
+ .IsNothing ()) {
735
+ return MaybeLocal<Object>();
736
+ }
718
737
719
- if (exit_status_ >= 0 )
720
- js_result->Set (context, env ()->output_string (),
721
- BuildOutputArray ()).Check ();
722
- else
723
- js_result->Set (context, env ()->output_string (),
724
- Null (env ()->isolate ())).Check ();
738
+ if (exit_status_ >= 0 ) {
739
+ Local<Array> out;
740
+ if (!BuildOutputArray ().ToLocal (&out) ||
741
+ js_result->Set (context, env ()->output_string (), out).IsNothing ()) {
742
+ return MaybeLocal<Object>();
743
+ }
744
+ } else if (js_result
745
+ ->Set (context, env ()->output_string (), Null (env ()->isolate ()))
746
+ .IsNothing ()) {
747
+ return MaybeLocal<Object>();
748
+ }
725
749
726
- js_result->Set (context, env ()->pid_string (),
727
- Number::New (env ()->isolate (), uv_process_.pid )).Check ();
750
+ if (js_result
751
+ ->Set (context,
752
+ env ()->pid_string (),
753
+ Number::New (env ()->isolate (), uv_process_.pid ))
754
+ .IsNothing ()) {
755
+ return MaybeLocal<Object>();
756
+ }
728
757
729
758
return scope.Escape (js_result);
730
759
}
731
760
732
-
733
- Local<Array> SyncProcessRunner::BuildOutputArray () {
761
+ MaybeLocal<Array> SyncProcessRunner::BuildOutputArray () {
734
762
CHECK_GE (lifecycle_, kInitialized );
735
763
CHECK (!stdio_pipes_.empty ());
736
764
@@ -739,10 +767,14 @@ Local<Array> SyncProcessRunner::BuildOutputArray() {
739
767
740
768
for (uint32_t i = 0 ; i < stdio_pipes_.size (); i++) {
741
769
SyncProcessStdioPipe* h = stdio_pipes_[i].get ();
742
- if (h != nullptr && h->writable ())
743
- js_output[i] = h->GetOutputAsBuffer (env ());
744
- else
770
+ if (h == nullptr || !h->writable ()) {
745
771
js_output[i] = Null (env ()->isolate ());
772
+ continue ;
773
+ }
774
+
775
+ if (!h->GetOutputAsBuffer (env ()).ToLocal (&js_output[i])) {
776
+ return MaybeLocal<Array>();
777
+ }
746
778
}
747
779
748
780
return scope.Escape (
@@ -759,9 +791,11 @@ Maybe<int> SyncProcessRunner::ParseOptions(Local<Value> js_value) {
759
791
Local<Context> context = env ()->context ();
760
792
Local<Object> js_options = js_value.As <Object>();
761
793
762
- Local<Value> js_file =
763
- js_options->Get (context, env ()->file_string ()).ToLocalChecked ();
764
- if (!CopyJsString (js_file, &file_buffer_).To (&r)) return Nothing<int >();
794
+ Local<Value> js_file;
795
+ if (!js_options->Get (context, env ()->file_string ()).ToLocal (&js_file) ||
796
+ !CopyJsString (js_file, &file_buffer_).To (&r)) {
797
+ return Nothing<int >();
798
+ }
765
799
if (r < 0 ) return Just (r);
766
800
uv_process_options_.file = file_buffer_;
767
801
@@ -774,104 +808,154 @@ Maybe<int> SyncProcessRunner::ParseOptions(Local<Value> js_value) {
774
808
return Just<int >(UV_EINVAL);
775
809
#endif
776
810
777
- Local<Value> js_args =
778
- js_options->Get (context, env ()->args_string ()).ToLocalChecked ();
779
- if (!CopyJsStringArray (js_args, &args_buffer_).To (&r)) return Nothing<int >();
811
+ Local<Value> js_args;
812
+ if (!js_options->Get (context, env ()->args_string ()).ToLocal (&js_args) ||
813
+ !CopyJsStringArray (js_args, &args_buffer_).To (&r)) {
814
+ return Nothing<int >();
815
+ }
780
816
if (r < 0 ) return Just (r);
781
817
uv_process_options_.args = reinterpret_cast <char **>(args_buffer_);
782
818
783
- Local<Value> js_cwd =
784
- js_options->Get (context, env ()->cwd_string ()).ToLocalChecked ();
785
- if (IsSet (js_cwd)) {
786
- if (!CopyJsString (js_cwd, &cwd_buffer_).To (&r)) return Nothing<int >();
819
+ Local<Value> js_cwd;
820
+ if (!js_options->Get (context, env ()->cwd_string ()).ToLocal (&js_cwd)) {
821
+ return Nothing<int >();
822
+ }
823
+ if (!js_cwd->IsNullOrUndefined ()) {
824
+ if (!CopyJsString (js_cwd, &cwd_buffer_).To (&r)) {
825
+ return Nothing<int >();
826
+ }
787
827
if (r < 0 ) return Just (r);
788
828
uv_process_options_.cwd = cwd_buffer_;
789
829
}
790
830
791
- Local<Value> js_env_pairs =
792
- js_options->Get (context, env ()->env_pairs_string ()).ToLocalChecked ();
793
- if (IsSet (js_env_pairs)) {
794
- if (!CopyJsStringArray (js_env_pairs, &env_buffer_).To (&r))
831
+ Local<Value> js_env_pairs;
832
+ if (!js_options->Get (context, env ()->env_pairs_string ())
833
+ .ToLocal (&js_env_pairs)) {
834
+ return Nothing<int >();
835
+ }
836
+ if (!js_env_pairs->IsNullOrUndefined ()) {
837
+ if (!CopyJsStringArray (js_env_pairs, &env_buffer_).To (&r)) {
795
838
return Nothing<int >();
839
+ }
796
840
if (r < 0 ) return Just (r);
797
841
798
842
uv_process_options_.env = reinterpret_cast <char **>(env_buffer_);
799
843
}
800
- Local<Value> js_uid =
801
- js_options->Get (context, env ()->uid_string ()).ToLocalChecked ();
802
- if (IsSet (js_uid)) {
803
- CHECK (js_uid->IsInt32 ());
844
+ Local<Value> js_uid;
845
+ if (!js_options->Get (context, env ()->uid_string ()).ToLocal (&js_uid)) {
846
+ return Nothing<int >();
847
+ }
848
+ if (!js_uid->IsNullOrUndefined ()) {
849
+ if (!js_uid->IsInt32 ()) {
850
+ THROW_ERR_INVALID_ARG_TYPE (env (),
851
+ " options.uid must be a 32-bit signed integer" );
852
+ return Nothing<int >();
853
+ }
804
854
const int32_t uid = js_uid.As <Int32>()->Value ();
805
855
uv_process_options_.uid = static_cast <uv_uid_t >(uid);
806
856
uv_process_options_.flags |= UV_PROCESS_SETUID;
807
857
}
808
858
809
- Local<Value> js_gid =
810
- js_options->Get (context, env ()->gid_string ()).ToLocalChecked ();
811
- if (IsSet (js_gid)) {
812
- CHECK (js_gid->IsInt32 ());
859
+ Local<Value> js_gid;
860
+ if (!js_options->Get (context, env ()->gid_string ()).ToLocal (&js_gid)) {
861
+ return Nothing<int >();
862
+ }
863
+ if (!js_gid->IsNullOrUndefined ()) {
864
+ if (!js_gid->IsInt32 ()) {
865
+ THROW_ERR_INVALID_ARG_TYPE (env (),
866
+ " options.gid must be a 32-bit signed integer" );
867
+ return Nothing<int >();
868
+ }
813
869
const int32_t gid = js_gid.As <Int32>()->Value ();
814
870
uv_process_options_.gid = static_cast <uv_gid_t >(gid);
815
871
uv_process_options_.flags |= UV_PROCESS_SETGID;
816
872
}
817
873
818
- Local<Value> js_detached =
819
- js_options->Get (context, env ()->detached_string ()).ToLocalChecked ();
820
- if (js_detached->BooleanValue (isolate))
874
+ Local<Value> js_detached;
875
+ if (!js_options->Get (context, env ()->detached_string ())
876
+ .ToLocal (&js_detached)) {
877
+ return Nothing<int >();
878
+ }
879
+ if (js_detached->BooleanValue (isolate)) {
821
880
uv_process_options_.flags |= UV_PROCESS_DETACHED;
881
+ }
822
882
823
- Local<Value> js_win_hide =
824
- js_options->Get (context, env ()->windows_hide_string ()).ToLocalChecked ();
825
- if (js_win_hide->BooleanValue (isolate))
883
+ Local<Value> js_win_hide;
884
+ if (!js_options->Get (context, env ()->windows_hide_string ())
885
+ .ToLocal (&js_win_hide)) {
886
+ return Nothing<int >();
887
+ }
888
+ if (js_win_hide->BooleanValue (isolate)) {
826
889
uv_process_options_.flags |= UV_PROCESS_WINDOWS_HIDE;
890
+ }
827
891
828
- if (env ()->hide_console_windows ())
892
+ if (env ()->hide_console_windows ()) {
829
893
uv_process_options_.flags |= UV_PROCESS_WINDOWS_HIDE_CONSOLE;
894
+ }
830
895
831
- Local<Value> js_wva =
832
- js_options->Get (context, env ()->windows_verbatim_arguments_string ())
833
- .ToLocalChecked ();
896
+ Local<Value> js_wva;
897
+ if (!js_options->Get (context, env ()->windows_verbatim_arguments_string ())
898
+ .ToLocal (&js_wva)) {
899
+ return Nothing<int >();
900
+ }
834
901
835
- if (js_wva->BooleanValue (isolate))
902
+ if (js_wva->BooleanValue (isolate)) {
836
903
uv_process_options_.flags |= UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS;
904
+ }
837
905
838
- Local<Value> js_timeout =
839
- js_options->Get (context, env ()->timeout_string ()).ToLocalChecked ();
840
- if (IsSet (js_timeout)) {
841
- CHECK (js_timeout->IsNumber ());
906
+ Local<Value> js_timeout;
907
+ if (!js_options->Get (context, env ()->timeout_string ()).ToLocal (&js_timeout)) {
908
+ return Nothing<int >();
909
+ }
910
+ if (!js_timeout->IsNullOrUndefined ()) {
911
+ if (!js_timeout->IsNumber ()) {
912
+ THROW_ERR_INVALID_ARG_TYPE (env (), " options.timeout must be a number" );
913
+ return Nothing<int >();
914
+ }
842
915
int64_t timeout = js_timeout->IntegerValue (context).FromJust ();
843
916
timeout_ = static_cast <uint64_t >(timeout);
844
917
}
845
918
846
- Local<Value> js_max_buffer =
847
- js_options->Get (context, env ()->max_buffer_string ()).ToLocalChecked ();
848
- if (IsSet (js_max_buffer)) {
849
- CHECK (js_max_buffer->IsNumber ());
919
+ Local<Value> js_max_buffer;
920
+ if (!js_options->Get (context, env ()->max_buffer_string ())
921
+ .ToLocal (&js_max_buffer)) {
922
+ return Nothing<int >();
923
+ }
924
+ if (!js_max_buffer->IsNullOrUndefined ()) {
925
+ if (!js_max_buffer->IsNumber ()) {
926
+ THROW_ERR_INVALID_ARG_TYPE (env (), " options.maxBuffer must be a number" );
927
+ return Nothing<int >();
928
+ }
850
929
max_buffer_ = js_max_buffer->NumberValue (context).FromJust ();
851
930
}
852
931
853
- Local<Value> js_kill_signal =
854
- js_options->Get (context, env ()->kill_signal_string ()).ToLocalChecked ();
855
- if (IsSet (js_kill_signal)) {
856
- CHECK (js_kill_signal->IsInt32 ());
932
+ Local<Value> js_kill_signal;
933
+ if (!js_options->Get (context, env ()->kill_signal_string ())
934
+ .ToLocal (&js_kill_signal)) {
935
+ return Nothing<int >();
936
+ }
937
+ if (!js_kill_signal->IsNullOrUndefined ()) {
938
+ if (!js_kill_signal->IsNumber ()) {
939
+ THROW_ERR_INVALID_ARG_TYPE (env (), " options.killSignal must be a number" );
940
+ return Nothing<int >();
941
+ }
857
942
kill_signal_ = js_kill_signal.As <Int32>()->Value ();
858
943
}
859
944
860
- Local<Value> js_stdio =
861
- js_options->Get (context, env ()->stdio_string ()).ToLocalChecked ();
862
- r = ParseStdioOptions (js_stdio);
863
- if (r < 0 ) return Just (r);
945
+ Local<Value> js_stdio;
946
+ if (!js_options->Get (context, env ()->stdio_string ()).ToLocal (&js_stdio) ||
947
+ !ParseStdioOptions (js_stdio).To (&r)) {
948
+ return Nothing<int >();
949
+ }
864
950
865
- return Just (0 );
951
+ return Just (r );
866
952
}
867
953
868
-
869
- int SyncProcessRunner::ParseStdioOptions (Local<Value> js_value) {
954
+ Maybe<int > SyncProcessRunner::ParseStdioOptions (Local<Value> js_value) {
870
955
HandleScope scope (env ()->isolate ());
871
956
Local<Array> js_stdio_options;
872
957
873
- if (!js_value->IsArray ())
874
- return UV_EINVAL;
958
+ if (!js_value->IsArray ()) return Just<int >(UV_EINVAL);
875
959
876
960
Local<Context> context = env ()->context ();
877
961
js_stdio_options = js_value.As <Array>();
@@ -884,73 +968,90 @@ int SyncProcessRunner::ParseStdioOptions(Local<Value> js_value) {
884
968
stdio_pipes_initialized_ = true ;
885
969
886
970
for (uint32_t i = 0 ; i < stdio_count_; i++) {
887
- Local<Value> js_stdio_option =
888
- js_stdio_options->Get (context, i).ToLocalChecked ();
971
+ Local<Value> js_stdio_option;
972
+ if (!js_stdio_options->Get (context, i).ToLocal (&js_stdio_option)) {
973
+ return Nothing<int >();
974
+ }
889
975
890
- if (!js_stdio_option->IsObject ())
891
- return UV_EINVAL;
976
+ if (!js_stdio_option->IsObject ()) {
977
+ return Just<int >(UV_EINVAL);
978
+ }
892
979
893
- int r = ParseStdioOption (i, js_stdio_option.As <Object>());
894
- if (r < 0 )
895
- return r;
980
+ int r;
981
+ if (!ParseStdioOption (i, js_stdio_option.As <Object>()).To (&r)) {
982
+ return Nothing<int >();
983
+ }
984
+ if (r < 0 ) {
985
+ return Just<int >(r);
986
+ }
896
987
}
897
988
898
989
uv_process_options_.stdio = uv_stdio_containers_;
899
990
uv_process_options_.stdio_count = stdio_count_;
900
991
901
- return 0 ;
992
+ return Just< int >( 0 ) ;
902
993
}
903
994
904
-
905
- int SyncProcessRunner::ParseStdioOption (int child_fd,
906
- Local<Object> js_stdio_option) {
995
+ Maybe<int > SyncProcessRunner::ParseStdioOption (int child_fd,
996
+ Local<Object> js_stdio_option) {
907
997
Local<Context> context = env ()->context ();
908
- Local<Value> js_type =
909
- js_stdio_option->Get (context, env ()->type_string ()).ToLocalChecked ();
998
+ Local<Value> js_type;
999
+ if (!js_stdio_option->Get (context, env ()->type_string ()).ToLocal (&js_type)) {
1000
+ return Nothing<int >();
1001
+ }
910
1002
911
1003
if (js_type->StrictEquals (env ()->ignore_string ())) {
912
- return AddStdioIgnore (child_fd);
913
-
1004
+ return Just (AddStdioIgnore (child_fd));
914
1005
} else if (js_type->StrictEquals (env ()->pipe_string ())) {
915
1006
Isolate* isolate = env ()->isolate ();
916
1007
Local<String> rs = env ()->readable_string ();
917
1008
Local<String> ws = env ()->writable_string ();
918
1009
919
- bool readable = js_stdio_option->Get (context, rs)
920
- .ToLocalChecked ()->BooleanValue (isolate);
921
- bool writable =
922
- js_stdio_option->Get (context, ws)
923
- .ToLocalChecked ()->BooleanValue (isolate);
1010
+ Local<Value> value;
1011
+ if (!js_stdio_option->Get (context, rs).ToLocal (&value)) {
1012
+ return Nothing<int >();
1013
+ }
1014
+ auto readable = value->BooleanValue (isolate);
1015
+
1016
+ if (!js_stdio_option->Get (context, ws).ToLocal (&value)) {
1017
+ return Nothing<int >();
1018
+ }
1019
+ bool writable = value->BooleanValue (isolate);
924
1020
925
1021
uv_buf_t buf = uv_buf_init (nullptr , 0 );
926
1022
927
1023
if (readable) {
928
- Local<Value> input =
929
- js_stdio_option->Get (context, env ()->input_string ()).ToLocalChecked ();
1024
+ Local<Value> input;
1025
+ if (!js_stdio_option->Get (context, env ()->input_string ())
1026
+ .ToLocal (&input)) {
1027
+ return Nothing<int >();
1028
+ }
930
1029
if (Buffer::HasInstance (input)) {
931
1030
buf = uv_buf_init (Buffer::Data (input),
932
1031
static_cast <unsigned int >(Buffer::Length (input)));
933
1032
} else if (!input->IsUndefined () && !input->IsNull ()) {
934
1033
// Strings, numbers etc. are currently unsupported. It's not possible
935
1034
// to create a buffer for them here because there is no way to free
936
1035
// them afterwards.
937
- return UV_EINVAL;
1036
+ return Just< int >( UV_EINVAL) ;
938
1037
}
939
1038
}
940
1039
941
- return AddStdioPipe (child_fd, readable, writable, buf);
1040
+ return Just ( AddStdioPipe (child_fd, readable, writable, buf) );
942
1041
943
1042
} else if (js_type->StrictEquals (env ()->inherit_string ()) ||
944
1043
js_type->StrictEquals (env ()->fd_string ())) {
945
- int inherit_fd = js_stdio_option->Get (context, env ()->fd_string ())
946
- .ToLocalChecked ()->Int32Value (context).FromJust ();
947
- return AddStdioInheritFD (child_fd, inherit_fd);
948
-
949
- } else {
950
- UNREACHABLE (" invalid child stdio type" );
1044
+ Local<Value> val;
1045
+ int inherit_fd;
1046
+ if (!js_stdio_option->Get (context, env ()->fd_string ()).ToLocal (&val) ||
1047
+ !val->Int32Value (context).To (&inherit_fd)) {
1048
+ return Nothing<int >();
1049
+ }
1050
+ return Just (AddStdioInheritFD (child_fd, inherit_fd));
951
1051
}
952
- }
953
1052
1053
+ UNREACHABLE (" invalid child stdio type" );
1054
+ }
954
1055
955
1056
int SyncProcessRunner::AddStdioIgnore (uint32_t child_fd) {
956
1057
CHECK_LT (child_fd, stdio_count_);
@@ -997,11 +1098,6 @@ int SyncProcessRunner::AddStdioInheritFD(uint32_t child_fd, int inherit_fd) {
997
1098
return 0 ;
998
1099
}
999
1100
1000
-
1001
- bool SyncProcessRunner::IsSet (Local<Value> value) {
1002
- return !value->IsUndefined () && !value->IsNull ();
1003
- }
1004
-
1005
1101
Maybe<int > SyncProcessRunner::CopyJsString (Local<Value> js_value,
1006
1102
const char ** target) {
1007
1103
Isolate* isolate = env ()->isolate ();
@@ -1054,18 +1150,18 @@ Maybe<int> SyncProcessRunner::CopyJsStringArray(Local<Value> js_value,
1054
1150
// length of all strings, including room for a null terminator after every
1055
1151
// string. Align strings to cache lines.
1056
1152
for (uint32_t i = 0 ; i < length; i++) {
1057
- auto value = js_array->Get (context, i).ToLocalChecked ();
1153
+ Local<Value> value;
1154
+ if (!js_array->Get (context, i).ToLocal (&value)) {
1155
+ return Nothing<int >();
1156
+ }
1058
1157
1059
1158
if (!value->IsString ()) {
1060
1159
Local<String> string;
1061
1160
if (!value->ToString (env ()->isolate ()->GetCurrentContext ())
1062
- .ToLocal (&string))
1161
+ .ToLocal (&string) ||
1162
+ js_array->Set (context, i, string).IsNothing ()) {
1063
1163
return Nothing<int >();
1064
- js_array
1065
- ->Set (context,
1066
- i,
1067
- string)
1068
- .Check ();
1164
+ }
1069
1165
}
1070
1166
1071
1167
Maybe<size_t > maybe_size = StringBytes::StorageSize (isolate, value, UTF8);
@@ -1081,7 +1177,10 @@ Maybe<int> SyncProcessRunner::CopyJsStringArray(Local<Value> js_value,
1081
1177
1082
1178
for (uint32_t i = 0 ; i < length; i++) {
1083
1179
list[i] = buffer + data_offset;
1084
- auto value = js_array->Get (context, i).ToLocalChecked ();
1180
+ Local<Value> value;
1181
+ if (!js_array->Get (context, i).ToLocal (&value)) {
1182
+ return Nothing<int >();
1183
+ }
1085
1184
data_offset += StringBytes::Write (isolate,
1086
1185
buffer + data_offset,
1087
1186
-1 ,
0 commit comments