diff --git a/src/workerd/api/streams/standard.c++ b/src/workerd/api/streams/standard.c++ index c318d6d18f35..44b8ab1c49c6 100644 --- a/src/workerd/api/streams/standard.c++ +++ b/src/workerd/api/streams/standard.c++ @@ -3638,12 +3638,12 @@ jsg::Promise WritableStreamJsController::pipeLoop(jsg::Lock& js) { return pipeLoop(js); } - auto onSuccess = JSG_VISITABLE_LAMBDA( + auto onSuccess = JSG_VISITABLE_LAMBDA2( (this, ref=addRef()), (ref), (jsg::Lock& js) { return pipeLoop(js); }); - auto onFailure = JSG_VISITABLE_LAMBDA( + auto onFailure = JSG_VISITABLE_LAMBDA2( (ref=addRef(),&source, preventCancel, pipeThrough), (ref), (jsg::Lock& js, jsg::Value value) { // The write failed. We handle it here because the pipe lock will have been released. diff --git a/src/workerd/jsg/function.h b/src/workerd/jsg/function.h index 7a8a7c983e9a..bb56a991f1c5 100644 --- a/src/workerd/jsg/function.h +++ b/src/workerd/jsg/function.h @@ -519,4 +519,9 @@ template <> constexpr bool isGcVisitor() { return true; } } \ }) +// Clang format encounters a segfault when JSG_VISITABLE_LAMBDA is called from inside of a +// JSG_VISITABLE_LAMBDA, if we call JSG_VISITABLE_LAMBDA through JSG_VISITABLE_LAMBDA2 it works. +#define JSG_VISITABLE_LAMBDA2(CAPTURES, VISITS, ...) JSG_VISITABLE_LAMBDA(CAPTURES, VISITS, __VA_ARGS__) + + } // namespace workerd::jsg