Scratch that, the issue was higher up in our SWIG layer. v8 is all good :D On Thursday, August 19, 2021 at 9:28:28 PM UTC-5 Will Lucas wrote:
> Hi all! > > I've been trying to upgrade our C++ backend to use the Node.js LTS > 14.15.5. Previously, I would store and retrieve a Buffer object with a > simple byte buffer as follows: > > *Storing the data:* > v8::Isolate* isolate = v8::Isolate::GetCurrent(); > v8::Local<v8::Context> context = v8::Context::New(isolate); > v8::Local<v8::Object> matObj = v8::Object::New(isolate); > > v8::Local<v8::Object> buffer = node::Buffer::Copy(isolate, > reinterpret_cast<const char*>(source.data), > source.total()).ToLocalChecked(); > matObj->Set(context, v8::String::NewFromUtf8Literal(isolate, "data"), > buffer).Check(); > > *Retrieving the data:* > v8::Isolate* isolate = v8::Isolate::GetCurrent(); > v8::Local<v8::Context> context = v8::Context::New(isolate); > v8::Local<v8::Object> inputObj = input->ToObject(context).ToLocalChecked(); > v8::Local<v8::Value> dataValue = inputObj->Get(context, > v8::String::NewFromUtf8Literal(isolate, "data")).ToLocalChecked(); > > char* data = node::Buffer::Data(dataValue); > > Unfortunately, this now results in an assertion trying to check that > dataValue is an ArrayBufferView: > node[451684]: ../src/node_buffer.cc:243:char* > node::Buffer::Data(v8::Local<v8::Value>): Assertion > `val->IsArrayBufferView()' failed. > 1: 0xa25510 node::Abort() [node] > 2: 0xa2558e [node] > 3: 0x9fd3fa node::Buffer::Data(v8::Local<v8::Value>) [node] > 4: 0x7fa42d0320ae [/home/wlucas/CLionProjects/test.node] > 5: 0xc066ab [node] > 6: 0xc07c56 [node] > 7: 0xc082d6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, > v8::internal::Isolate*) [node] > 8: 0x14269f9 [node] > Aborted (core dumped) > > Is there some type of casting required now, or should I be using the > BackingStore with Uint8Array now instead of Buffer? > > Thanks for any advice! > Will > > > > > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/157eea42-27c9-4ad1-873e-9814a58083fcn%40googlegroups.com.