From 6de7bc7e45d403d6d8c7709f53d6020ecf73fa3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Wed, 4 Oct 2023 11:19:33 -0700 Subject: [PATCH 1/3] Fix a race condition preventing embedded compiler to shutdown after a protocol error --- lib/src/embedded/dispatcher.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/src/embedded/dispatcher.dart b/lib/src/embedded/dispatcher.dart index e9e723bfc..a1b20b5d4 100644 --- a/lib/src/embedded/dispatcher.dart +++ b/lib/src/embedded/dispatcher.dart @@ -237,7 +237,17 @@ final class Dispatcher { _send(OutboundMessage()..logEvent = event); /// Sends [error] to the host. - void sendError(ProtocolError error) => + /// + /// This is used during compilation by other classes like host callable. + /// Therefore it must set _requestError = true to prevent sending a CompileFailure after + /// sending a ProtocolError. + void sendError(ProtocolError error) { + _sendError(error); + _requestError = true; + } + + /// Sends [error] to the host. + void _sendError(ProtocolError error) => _send(OutboundMessage()..error = error); InboundMessage_CanonicalizeResponse sendCanonicalizeRequest( @@ -323,7 +333,7 @@ final class Dispatcher { /// The [messageId] indicate the IDs of the message being responded to, if /// available. void _handleError(Object error, StackTrace stackTrace, {int? messageId}) { - sendError(handleError(error, stackTrace, messageId: messageId)); + _sendError(handleError(error, stackTrace, messageId: messageId)); } /// Sends [message] to the host with the given [wireId]. From f78288de79b53656eaa0dbcfa052937eec3c8c82 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 4 Oct 2023 16:29:30 -0700 Subject: [PATCH 2/3] Add a CHANGELOG entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84aba9723..ccaaeca8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ * Deprecate `Deprecation.calcInterp` since it was never actually emitted as a deprecation. +### Embedded Sass + +* Fix a rare race condition in the embedded compiler that could be triggered by + a protocol error and cause a crash. + ## 1.68.0 * Fix the source spans associated with the `abs-percent` deprecation. From 024a0541e853f0d21cd935d1fd48aa373bf61721 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 4 Oct 2023 16:45:59 -0700 Subject: [PATCH 3/3] Clarify changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccaaeca8d..a68d7688f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ ### Embedded Sass -* Fix a rare race condition in the embedded compiler that could be triggered by - a protocol error and cause a crash. +* Fix a rare race condition where the embedded compiler could freeze when a + protocol error was immediately followed by another request. ## 1.68.0