mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
resolve more comments
This commit is contained in:
@@ -276,7 +276,7 @@ const DeferredPromise = struct {
|
||||
self.route_bundle_indices.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
pub fn deinit(self: *DeferredPromise) void {
|
||||
pub fn deinitIdempotently(self: *DeferredPromise) void {
|
||||
self.strong.deinit();
|
||||
self.route_bundle_indices.deinit(bun.default_allocator);
|
||||
self.route_bundle_indices = .{};
|
||||
@@ -674,7 +674,7 @@ pub fn deinit(dev: *DevServer) void {
|
||||
r = request.next;
|
||||
}
|
||||
dev.next_bundle.route_queue.deinit(alloc);
|
||||
dev.next_bundle.promise.deinit();
|
||||
dev.next_bundle.promise.deinitIdempotently();
|
||||
},
|
||||
.route_lookup = dev.route_lookup.deinit(alloc),
|
||||
.source_maps = {
|
||||
@@ -2201,7 +2201,7 @@ pub fn finalizeBundle(
|
||||
defer {
|
||||
var heap = bv2.graph.heap;
|
||||
bv2.deinitWithoutFreeingArena();
|
||||
if (dev.current_bundle) |*cb| cb.promise.deinit();
|
||||
if (dev.current_bundle) |*cb| cb.promise.deinitIdempotently();
|
||||
dev.current_bundle = null;
|
||||
dev.log.clearAndFree();
|
||||
heap.deinit();
|
||||
@@ -2946,7 +2946,7 @@ pub fn finalizeBundle(
|
||||
}
|
||||
|
||||
if (current_bundle.promise.strong.hasValue()) {
|
||||
defer current_bundle.promise.deinit();
|
||||
defer current_bundle.promise.deinitIdempotently();
|
||||
current_bundle.promise.setRouteBundleState(dev, .loaded);
|
||||
dev.vm.eventLoop().enter();
|
||||
current_bundle.promise.strong.resolve(dev.vm.global, JSValue.true);
|
||||
|
||||
@@ -23,29 +23,25 @@ pub fn setAdditionalOnAbortCallback(self: AnyRequestContext, cb: ?AdditionalOnAb
|
||||
return;
|
||||
}
|
||||
|
||||
var old: ?AdditionalOnAbortCallback = null;
|
||||
switch (self.tagged_pointer.tag()) {
|
||||
@field(Pointer.Tag, bun.meta.typeBaseName(@typeName(HTTPServer.RequestContext))) => {
|
||||
old = self.tagged_pointer.as(HTTPServer.RequestContext).additional_on_abort;
|
||||
bun.assert(self.tagged_pointer.as(HTTPServer.RequestContext).additional_on_abort == null);
|
||||
self.tagged_pointer.as(HTTPServer.RequestContext).additional_on_abort = cb;
|
||||
},
|
||||
@field(Pointer.Tag, bun.meta.typeBaseName(@typeName(HTTPSServer.RequestContext))) => {
|
||||
old = self.tagged_pointer.as(HTTPSServer.RequestContext).additional_on_abort;
|
||||
bun.assert(self.tagged_pointer.as(HTTPSServer.RequestContext).additional_on_abort == null);
|
||||
self.tagged_pointer.as(HTTPSServer.RequestContext).additional_on_abort = cb;
|
||||
},
|
||||
@field(Pointer.Tag, bun.meta.typeBaseName(@typeName(DebugHTTPServer.RequestContext))) => {
|
||||
old = self.tagged_pointer.as(DebugHTTPServer.RequestContext).additional_on_abort;
|
||||
bun.assert(self.tagged_pointer.as(DebugHTTPServer.RequestContext).additional_on_abort == null);
|
||||
self.tagged_pointer.as(DebugHTTPServer.RequestContext).additional_on_abort = cb;
|
||||
},
|
||||
@field(Pointer.Tag, bun.meta.typeBaseName(@typeName(DebugHTTPSServer.RequestContext))) => {
|
||||
old = self.tagged_pointer.as(DebugHTTPSServer.RequestContext).additional_on_abort;
|
||||
bun.assert(self.tagged_pointer.as(DebugHTTPSServer.RequestContext).additional_on_abort == null);
|
||||
self.tagged_pointer.as(DebugHTTPSServer.RequestContext).additional_on_abort = cb;
|
||||
},
|
||||
else => @panic("Unexpected AnyRequestContext tag"),
|
||||
}
|
||||
if (old != null) {
|
||||
old.?.deref();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn memoryCost(self: AnyRequestContext) usize {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "BakeAdditionsToGlobalObject.h"
|
||||
#include "JSBakeResponse.h"
|
||||
#include "JSBunRequest.h"
|
||||
#include "JavaScriptCore/SlotVisitorMacros.h"
|
||||
#include "ErrorCode.h"
|
||||
|
||||
@@ -103,9 +104,9 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetBundleNewRouteJSFunction, (JSC::JSGlob
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
JSRequest* request = jsDynamicCast<JSRequest*>(requestValue);
|
||||
JSBunRequest* request = jsDynamicCast<JSBunRequest*>(requestValue);
|
||||
if (!request) {
|
||||
Bun::throwError(globalObject, scope, ErrorCode::ERR_INVALID_ARG_TYPE, "request must be a JSRequest"_s);
|
||||
Bun::throwError(globalObject, scope, ErrorCode::ERR_INVALID_ARG_TYPE, "request must be a JSBunRequest"_s);
|
||||
return JSValue::encode(jsUndefined());
|
||||
}
|
||||
|
||||
@@ -116,6 +117,7 @@ BUN_DEFINE_HOST_FUNCTION(jsFunctionBakeGetBundleNewRouteJSFunction, (JSC::JSGlob
|
||||
}
|
||||
|
||||
BunString url = Bun::toString(urlValue.getString(globalObject));
|
||||
RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(jsUndefined()));
|
||||
|
||||
return Bake__bundleNewRouteJSFunctionImpl(globalObject, request->m_ctx, url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user