vm: hint module identifier in instantiate errors · nodejs/node@1986ee4 · GitHub
Skip to content

Commit 1986ee4

Browse files
authored
vm: hint module identifier in instantiate errors
PR-URL: #60199 Fixes: #60157 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent d54e6ae commit 1986ee4

4 files changed

Lines changed: 28 additions & 17 deletions

File tree

src/module_wrap.cc

Lines changed: 13 additions & 12 deletions

src/module_wrap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class ModuleWrap : public BaseObject {
9999
public:
100100
enum InternalFields {
101101
kModuleSlot = BaseObject::kInternalFieldCount,
102-
kURLSlot,
103102
kModuleSourceObjectSlot,
104103
kSyntheticEvaluationStepsSlot,
105104
kContextObjectSlot, // Object whose creation context is the target Context
@@ -215,6 +214,7 @@ class ModuleWrap : public BaseObject {
215214
v8::Local<v8::FixedArray> import_attributes,
216215
v8::Local<v8::Module> referrer);
217216

217+
std::string url_;
218218
v8::Global<v8::Module> module_;
219219
ResolveCache resolve_cache_;
220220
contextify::ContextifyContext* contextify_context_ = nullptr;

src/node_errors.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ inline v8::Local<v8::Object> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) {
295295
}
296296

297297
inline void THROW_ERR_SOURCE_PHASE_NOT_DEFINED(v8::Isolate* isolate,
298-
v8::Local<v8::String> url) {
299-
std::string message = std::string(*v8::String::Utf8Value(isolate, url));
298+
const std::string& url) {
300299
return THROW_ERR_SOURCE_PHASE_NOT_DEFINED(
301300
isolate,
302-
"Source phase import object is not defined for module %s",
303-
message.c_str());
301+
"Source phase import object is not defined for module '%s'",
302+
url);
304303
}
305304

306305
inline v8::Local<v8::Object> ERR_STRING_TOO_LONG(v8::Isolate* isolate) {

test/parallel/test-vm-module-linkmodulerequests.js

Lines changed: 11 additions & 0 deletions

0 commit comments

Comments
 (0)