Flutter-Bounty-Hunters / static_shock

A static site generator for Dart.
MIT License
59 stars 5 forks source link

[CLI] - Dev server routinely crashes #76

Closed matthew-carroll closed 2 months ago

matthew-carroll commented 3 months ago

When running shock serve, the dev server routinely crashes when processing changes.

It's unclear what's causing the crash. My guess is that we're getting 2+ change notifications before the first rebuild completes and it's breaking something along the way. But I'm not sure about this.

Here's an example of an error message when the crash happens:

File system change (modify): /Users/admin/Projects/static_shock/static_shock/packages/static_shock_docs/source/styles/inner_page.scss.
Rebuilding the website.
Unhandled exception:
Bad state: StreamSink is bound to a stream
#0      _StreamSinkImpl._controller (dart:io/io_sink.dart:234:7)
#1      _StreamSinkImpl.add (dart:io/io_sink.dart:154:5)
#2      _IOSinkImpl.write (dart:io/io_sink.dart:287:5)
#3      _IOSinkImpl.writeln (dart:io/io_sink.dart:307:5)
#4      _StdSink.writeln (dart:io/stdio.dart:342:11)
#5      Logger.detail (package:mason_logger/src/mason_logger.dart:159:13)
#6      StaticShockDevServer._onSourceFileChange (package:static_shock_cli/src/dev_server.dart:171:10)
#7      _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#10     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:377:25)
#11     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
#12     _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#13     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#14     _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#15     _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#16     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#17     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#19     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#20     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:405:11)
#21     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#22     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

To reproduce this issue, open a source file, make a change, save, quickly make another change, save again.

matthew-carroll commented 3 months ago

Re-opening because this issue seems to still be happening. The root cause now isn't the Mason Logger - instead the same Sink error looks like it might be coming from shelf.