Skip to content

Commit

Permalink
Fix a race condition preventing embedded compiler to shutdown after a…
Browse files Browse the repository at this point in the history
… protocol error (#2106)

Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
  • Loading branch information
ntkme and nex3 authored Oct 5, 2023
1 parent 16b8512 commit 310904e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 12 additions & 2 deletions lib/src/embedded/dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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].
Expand Down

0 comments on commit 310904e

Please sign in to comment.