xvrh / puppeteer-dart

A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
BSD 3-Clause "New" or "Revised" License
236 stars 59 forks source link

Does it support run on Chrome 107? #226

Open nguyenthaituananh9x opened 1 year ago

nguyenthaituananh9x commented 1 year ago

Does it support run on Chrome 107?

xvrh commented 1 year ago

Yes it should. To prevent incompatibility issue, you probably want to use the version 2.16.0 of this library.

Post here if you have any specific error.

tbm98 commented 1 year ago

Yes it should. To prevent incompatibility issue, you probably want to use the version 2.16.0 of this library.

Post here if you have any specific error.

I will try

ninhngadev commented 1 year ago

Hi @xvrh. Is there any way I can use the library in the latest version of the code (bug fixed) but compatible with lower chrome versions, for example chrome 107?

xvrh commented 1 year ago

@ninhngadev it's possible that the latest version of this library works with chrome 107. But it's also possible that there is a breaking change in the protocol between v107 and v112. Since Dart has a sound type system any small change can easily trigger a null assertion error.

But I recommend that you try and show us any error you run into.

ninhngadev commented 1 year ago

I got a crash when run on chrome 107

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
#0      new ExecutionContextDestroyedEvent.fromJson (package:puppeteer/protocol/runtime.dart:546:66)
#1      RuntimeApi.onExecutionContextDestroyed.<anonymous closure> (package:puppeteer/protocol/runtime.dart:46:46)
#2      _MapStream._handleData (dart:async/stream_pipe.dart:213:31)
#3      _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#5      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#6      _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#7      _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#8      _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#10     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#11     _SyncBroadcastStreamController._sendData.<anonymous closure> (dart:async/broadcast_stream_controller.dart:385:20)
#12     _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:322:15)
#13     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:384:5)
#14     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
#15     Session._onMessage (package:puppeteer/src/connection.dart:259:24)
#16     Connection._onMessage (package:puppeteer/src/connection.dart:144:17)
#17     _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#18     CastStreamSubscription._onData (dart:_internal/async_cast.dart:85:11)
#19     _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#20     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#21     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#22     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#23     _StreamController._add (dart:async/stream_controller.dart:648:7)
#24     _StreamController.add (dart:async/stream_controller.dart:596:5)
#25     new _WebSocketImpl._fromSocket.<anonymous closure> (dart:_http/websocket_impl.dart:1144:21)
#26     _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#29     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
#30     _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
#31     _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
#32     _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
#33     _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
#34     _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#35     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#36     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#37     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#38     _StreamController._add (dart:async/stream_controller.dart:648:7)
#39     _StreamController.add (dart:async/stream_controller.dart:596:5)
#40     _Socket._onData (dart:io-patch/socket_patch.dart:2355:41)
#41     _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
#42     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#43     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#44     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#45     _StreamController._add (dart:async/stream_controller.dart:648:7)
#46     _StreamController.add (dart:async/stream_controller.dart:596:5)
#47     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1877:33)
#48     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1334:14)
#49     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#50     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#51     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#52     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)
ninhngadev commented 1 year ago

@xvrh. I just workaround by image but I don't know what the potential dangers would be in doing so.

xvrh commented 1 year ago

@ninhngadev yes this is exactly the kind of error I was expecting. Dart has sound null-safety now, so this is very easy to run into this kind of cast error when there is a version mismatch (between the version of the protocol and the chrome instance).

I think you can easily maintain your own fork of this library with your fixes applies to workaround the bug (until you can upgrade Chrome to a newer version).

ninhngadev commented 1 year ago

Thanks @xvrh. I think it's safe to close this issue.