We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9b19d7 commit 2dcf70cCopy full SHA for 2dcf70c
2 files changed
src/node_modules.cc
@@ -436,10 +436,13 @@ void BindingData::GetPackageScopeConfig(
436
}
437
438
void EnableCompileCache(const FunctionCallbackInfo<Value>& args) {
439
- CHECK(args[0]->IsString());
440
Isolate* isolate = args.GetIsolate();
441
Local<Context> context = isolate->GetCurrentContext();
442
Environment* env = Environment::GetCurrent(context);
+ if (!args[0]->IsString()) {
443
+ THROW_ERR_INVALID_ARG_TYPE(env, "cacheDir should be a string");
444
+ return;
445
+ }
446
Utf8Value value(isolate, args[0]);
447
CompileCacheEnableResult result = env->EnableCompileCache(*value);
448
std::vector<Local<Value>> values = {
test/parallel/test-compile-cache-api-error.js
@@ -0,0 +1,11 @@
1
+'use strict';
2
+
3
+// This tests module.enableCompileCache() throws when an invalid argument is passed.
4
5
+require('../common');
6
+const { enableCompileCache } = require('module');
7
+const assert = require('assert');
8
9
+for (const invalid of [0, null, false, () => {}, {}, []]) {
10
+ assert.throws(() => enableCompileCache(invalid), { code: 'ERR_INVALID_ARG_TYPE' });
11
+}
0 commit comments