Support Node.js 14

This commit is contained in:
Alex Hultman 2020-04-23 21:57:38 +02:00
parent 83bee418d2
commit bd9007eee0
4 changed files with 15 additions and 4 deletions

View File

@ -36,7 +36,8 @@ struct node_version {
{"v10.17.0", "64"},
{"v11.15.0", "67"},
{"v12.13.0", "72"},
{"v13.1.0", "79"}
{"v13.1.0", "79"},
{"v14.0.0", "83"}
};
/* Downloads headers, creates folders */

View File

@ -114,7 +114,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
CallJS(isolate, Local<Function>::New(isolate, messagePf), 3, argv);
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
messageArrayBuffer->Neuter();
NeuterArrayBuffer(messageArrayBuffer);
};
}
@ -173,7 +173,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
delete perSocketData->socketPf;
/* Again, here we clear the buffer to avoid strange bugs */
messageArrayBuffer->Neuter();
NeuterArrayBuffer(messageArrayBuffer);
};
app->template ws<PerSocketData>(std::string(pattern.getString()), std::move(behavior));

View File

@ -49,7 +49,7 @@ struct HttpResponseWrapper {
Local<Value> argv[] = {dataArrayBuffer, Boolean::New(isolate, last)};
CallJS(isolate, Local<Function>::New(isolate, p), 2, argv);
dataArrayBuffer->Neuter();
NeuterArrayBuffer(dataArrayBuffer);
});
args.GetReturnValue().Set(args.Holder());

View File

@ -40,6 +40,16 @@ bool BooleanValue(Isolate *isolate, Local<Value> value) {
#endif
}
void NeuterArrayBuffer(Local<ArrayBuffer> ab) {
#if V8_MAJOR_VERSION < 7 || (V8_MAJOR_VERSION == 7 && V8_MINOR_VERSION == 0)
/* Old */
ab->Neuter();
#else
/* Node.js 12, 13 */
ab->Detach();
#endif
}
#include "Utilities.h"
#include "WebSocketWrapper.h"
#include "HttpResponseWrapper.h"