Giter Site home page Giter Site logo

Comments (7)

s-ludwig avatar s-ludwig commented on June 9, 2024

It looks like this is using the overload of requestHTTP that returns the response instead of the one that passes it as scope to a callback. If that call is directly in your code, you could probably replace it with the scope version to work around the crash.

For the crash itself, it looks like might be an order-of-destruction issue, where the GC destroys the referenced ConnectionPool prior to the LockedConnection that is as part of the HTTPClientResponse. I'm not sure whether there is a simple fix (backwards compatible) within the library to avoid that, or if this is an obligation that needs to be passed to the user for now.

In the latter case, it would be necessary to catch the exception, either directly, or indirectly using a scope (failure) guard, and call HTTPClientResponse.disconnect() to ensure the response object frees any associated resources in time.

from vibe.d.

LunaTheFoxgirl avatar LunaTheFoxgirl commented on June 9, 2024

It looks like this is using the overload of requestHTTP that returns the response instead of the one that passes it as scope to a callback. If that call is directly in your code, you could probably replace it with the scope version to work around the crash.

Sadly no, I do not directly make the requestHTTP call, that is being done by connectWebSocket

from vibe.d.

s-ludwig avatar s-ludwig commented on June 9, 2024

Okay, then there is also an overload of connectWebSocket that takes a WebSocketHandshakeDelegate that internally uses the other connectHTTP overload. I'll have a look at the exception handling in the web socket module later.

from vibe.d.

LunaTheFoxgirl avatar LunaTheFoxgirl commented on June 9, 2024

From what I can tell, I can't use the scope callback as the socket has to be a long lived object that is queried in a loop in things like games.

from vibe.d.

s-ludwig avatar s-ludwig commented on June 9, 2024

Having it long lived shouldn't be an issue, the task is light-weight and as long as it doesn't perform heavy computations, it shouldn't interfere with anything else in the main thread. The task could then be connected to other tasks/threads by establishing a two-way communication channel, which, in contrast to std.concurrency, is strongly typed and doesn't allocate for each message.

from vibe.d.

LunaTheFoxgirl avatar LunaTheFoxgirl commented on June 9, 2024

I would need to figure out how to start/stop it on command, seems difficult considering how scope will destroy the object after it exits the scope

from vibe.d.

s-ludwig avatar s-ludwig commented on June 9, 2024

Channel has a close method and is reference counted (a copy would exist on both sides), so that could be used to safely communicate the end of the connection/scope.

from vibe.d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.