diff --git a/CHANGELOG.md b/CHANGELOG.md index c8885e206..abb205336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ * Deprecate `Deprecation.calcInterp` since it was never actually emitted as a deprecation. +### Embedded Sass + +* Fix a rare race condition where the embedded compiler could freeze when a + protocol error was immediately followed by another request. + ## 1.68.0 * Fix the source spans associated with the `abs-percent` deprecation. 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].