Comments (7)
@erikdubbelboer see if #27 is similar (though the panic happens on websocket disconnect). I made the pull request to fix the panic I'm facing by just avoiding sending the messages on a connection that is about to be closed.
Speaking of using multiple tabs, I also found that their usage is pretty limited (and in my case, I also want better security/isolation between running tasks). DevTools protocol has the notion of Targets and browser contexts which might help here. But in my project I decided to go further and always use a throw-away docker container to run each command. See it here: https://github.com/iafan/hc
from godet.
I'm not using remote.Close
so this is a different issue, your pull request will not fix this as in my case remote.isClosing
will stay false.
I need to load as many pages as fast as possible so using throw-away containers is waaay too slow. That's why I'm using multiple tabs for lower memory usage and each tab is fetching different pages at the same time. I don't think Targets and browser contexts have anything to do with this, they seem to be for using safe browsing and being able to load pages into different context where they don't share cookies and local storage.
from godet.
I have just added an example of opening multiple tabs in parallel, since it seems to be a hot topic :)
I will check into your panic. Is this on Linux ? (I normally do all my testing on a Mac)
Regarding changing the API to better support of multiple tabs, it's an interesting idea and I have given it a little thought (again, somebody else had a problem with multiple tabs). While it would make the API more clear and easier to use, using multiple RemoteDebuggers is not really that bad and if you look at it, the RemoteDebugger object is pretty much all about managing the connected tab.
Anyway, again, I will give it some more thought. Thanks!
from godet.
Can you update and try again ?
from godet.
I can tell you that doesn't fix a thing without even trying. Here is the real problem:
I call Connect()
which calls connectWs()
which sets ws
and starts readMessages()
in a goroutine.
Now before this goroutine has done anything Connect()
returns and my code calls NewTab()
which in turn calls connectWs()
again which starts another readMessages()
gorountine.
Now at this point both goroutines actually start and both call socket()
which returns the exact same ws
(the one that got set with NewTab()
). Then they both call ws.ReadMessage()
on the exact same ws
instance. gorilla/websocket
is not designed to be thread safe at all so as you can see this makes things panic immediately.
The fix is to not call socket()
in readMessages()
but instead get the socket as argument. In this case the first readMessages()
goroutine would just try to read from the ws
that was closed when I called NewTab()
.
from godet.
Ok, please try now.
from godet.
Yes that fixes it 👍
from godet.
Related Issues (20)
- How to handle multiple alert? HOT 4
- remote.CallbackEvent can not work on remote.NewTab HOT 3
- leaking goroutines HOT 1
- Error when connecting to local host HOT 4
- Emulate geolocation HOT 5
- how to make chrome load all resources of the page? HOT 9
- GetResponseBody bug HOT 1
- Can't run basic example - dependency issue HOT 1
- dependency issue httpclient reporting error HOT 1
- Have the `Connect` interface receive a map of headers HOT 1
- Open multiple profiles on multiple tabs HOT 2
- Custom proxy for every tab.
- Sending selenium commands HOT 1
- Control in a separate window HOT 1
- remote.FullfillRequest not working HOT 2
- Interface Conversion Error upon calling remote.SetCookie HOT 2
- Page event seem be not triggered HOT 2
- how to set "download_restrictions" by godet? HOT 1
- remote.FulfillRequest problem HOT 6
- Is this hub give the method to generate a HAR file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godet.