diff --git a/src/jsc/bindings/BunPlugin.cpp b/src/jsc/bindings/BunPlugin.cpp
index 5773394aed30..cc8c2d228554 100644
--- a/src/jsc/bindings/BunPlugin.cpp
+++ b/src/jsc/bindings/BunPlugin.cpp
@@ -302,12 +302,13 @@ static inline JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObje
auto targetValue = obj->getIfPropertyExists(globalObject, Identifier::fromString(vm, "target"_s));
RETURN_IF_EXCEPTION(throwScope, {});
if (targetValue) {
- if (auto* targetJSString = targetValue.toStringOrNull(globalObject)) {
- String targetString = targetJSString->value(globalObject);
- if (!(targetString == "node"_s || targetString == "bun"_s || targetString == "browser"_s)) {
- JSC::throwTypeError(globalObject, throwScope, "plugin target must be one of 'node', 'bun' or 'browser'"_s);
- return {};
- }
+ auto* targetJSString = targetValue.toString(globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ String targetString = targetJSString->value(globalObject);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ if (!(targetString == "node"_s || targetString == "bun"_s || targetString == "browser"_s)) {
+ JSC::throwTypeError(globalObject, throwScope, "plugin target must be one of 'node', 'bun' or 'browser'"_s);
+ return {};
}
}
diff --git a/test/js/bun/plugin/plugins.test.ts b/test/js/bun/plugin/plugins.test.ts
index 1ccd453b2246..f1ad19fc49dd 100644
--- a/test/js/bun/plugin/plugins.test.ts
+++ b/test/js/bun/plugin/plugins.test.ts
@@ -1,6 +1,6 @@
///