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
232 stars 59 forks source link

Flutter Web - Error: Unsupported operation: _Namespace #142

Open JojoGogo9 opened 3 years ago

JojoGogo9 commented 3 years ago

I'm trying to use puppeteer for Server Side Rendering, but get this exception - I believe because puppeteer relies on dart.io

Is it possible to move from dart.io to universal_io to support flutter web? (I apologize in advance if this won't fix the issue)

Uncaught (in promise) Error: Unsupported operation: Namespace at Object.throw [as throw] (errors.dart:236) at Function.get _namespace [as _namespace] (io_patch.dart:200) at Function.get systemTemp [as systemTemp] (directory_impl.dart:138) at Function.get systemTemp [as systemTemp] (directory.dart:203) at puppeteer.Puppeteer.__.launch (puppeteer.dart:136) at launch.next () at runBody (async_patch.dart:84) at Object._async [as async] (async_patch.dart:123) at puppeteer.Puppeteer.__.launch (puppeteer.dart:95) at getSiteMap (PuppeteerMethods.dart:9) at getSiteMap.next () at runBody (async_patch.dart:84) at Object._async [as async] (async_patch.dart:123) at Object.getSiteMap (PuppeteerMethods.dart:6) at main$ (main.dart:83) at main$.next () at async_patch.dart:45 at _RootZone.runUnary (zone.dart:1613) at _FutureListener.thenAwait.handleValue (future_impl.dart:155) at handleValueCallback (future_impl.dart:707) at Function._propagateToListeners (future_impl.dart:736) at _Future.new.[_complete] (future_impl.dart:533) at Object._cancelAndValue (stream_pipe.dart:61) at stream.dart:1219 at _RootZone.runUnaryGuarded (zone.dart:1546) at _BroadcastSubscription.new.[_sendData] (stream_impl.dart:341) at _BroadcastSubscription.new.[_add] (stream_impl.dart:271) at _SyncBroadcastStreamController.new.[_sendData] (broadcast_stream_controller.dart:378) at _SyncBroadcastStreamController.new.add (broadcast_stream_controller.dart:244) at auth.dart:307 at Object._checkAndCall (operations.dart:324) at Object.dcall (operations.dart:329) at ret (js_patch.dart:411) at auth.js:1462

xvrh commented 3 years ago

Hi, I think moving to universal_io is a good idea and can solve this problem. You won't be able to use the launch method in a browser (because it involves launching an OS process) but you will be able to use connect.

Alternatively, we could reorganise the methods and move launch to its own puppeteer_io.dart file (or create puppeteer_web.dart without it).