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
[email protected]
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/faf9c506-1700-4bd7-9d2f-9080bc204251n%40googlegroups.com.

Reply via email to