You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We just hit this bug, which may be a feature, but at least not documented where in Node.js
13, the napi_get_typedarray_info returns NULL as the data pointer for 0 length typedarrays but Node.js 12 returns a pointer.
It seems perfectly fine to me to return any pointer for a zero-length ArrayBuffer, including NULL.
In the case, the length shall always be respected even if the pointer is not NULL. But that is an elementary check over the return values, documenting it might increase the verbosity of the document.
We had logic there we checked if a pointer was NULL to see we had load it from the typed_array method, which this broke. As mentioned, it might be a feature but having it documented would have saved us debugging.
Activity
addaleax commentedon Mar 4, 2020
… what is the (un)expected behaviour here? It seems perfectly fine to me to return any pointer for a zero-length ArrayBuffer, including
NULL.(I’m guessing that this is happening because of V8’s
BackingStoremigration, but in this case that should just be an implementation detail.)legendecas commentedon Mar 4, 2020
In the case, the length shall always be respected even if the pointer is not
NULL. But that is an elementary check over the return values, documenting it might increase the verbosity of the document.mafintosh commentedon Mar 4, 2020
We had logic there we checked if a pointer was NULL to see we had load it from the typed_array method, which this broke. As mentioned, it might be a feature but having it documented would have saved us debugging.
doc: clarify behavior of napi_get_typedarray_info
doc: clarify behavior of napi_get_typedarray_info
doc: clarify behavior of napi_get_typedarray_info
fix(napi): check NAPI status before using pointers in fallback paths
fix(napi): check NAPI status before using pointers in fallback paths
doc: clarify behavior of napi_get_typedarray_info