Skip to content

Commit 310904e

Browse files
ntkmenex3
andauthored
Fix a race condition preventing embedded compiler to shutdown after a protocol error (#2106)
Co-authored-by: Natalie Weizenbaum <[email protected]>
1 parent 16b8512 commit 310904e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
* Deprecate `Deprecation.calcInterp` since it was never actually emitted as a
1010
deprecation.
1111

12+
### Embedded Sass
13+
14+
* Fix a rare race condition where the embedded compiler could freeze when a
15+
protocol error was immediately followed by another request.
16+
1217
## 1.68.0
1318

1419
* Fix the source spans associated with the `abs-percent` deprecation.

lib/src/embedded/dispatcher.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,17 @@ final class Dispatcher {
237237
_send(OutboundMessage()..logEvent = event);
238238

239239
/// Sends [error] to the host.
240-
void sendError(ProtocolError error) =>
240+
///
241+
/// This is used during compilation by other classes like host callable.
242+
/// Therefore it must set _requestError = true to prevent sending a CompileFailure after
243+
/// sending a ProtocolError.
244+
void sendError(ProtocolError error) {
245+
_sendError(error);
246+
_requestError = true;
247+
}
248+
249+
/// Sends [error] to the host.
250+
void _sendError(ProtocolError error) =>
241251
_send(OutboundMessage()..error = error);
242252

243253
InboundMessage_CanonicalizeResponse sendCanonicalizeRequest(
@@ -323,7 +333,7 @@ final class Dispatcher {
323333
/// The [messageId] indicate the IDs of the message being responded to, if
324334
/// available.
325335
void _handleError(Object error, StackTrace stackTrace, {int? messageId}) {
326-
sendError(handleError(error, stackTrace, messageId: messageId));
336+
_sendError(handleError(error, stackTrace, messageId: messageId));
327337
}
328338

329339
/// Sends [message] to the host with the given [wireId].

0 commit comments

Comments
 (0)