GithubHelp home page GithubHelp logo

Endless loop outside of tests about fork HOT 7 CLOSED

spatie avatar spatie commented on May 12, 2024
Endless loop outside of tests

from fork.

Comments (7)

dhrrgn avatar dhrrgn commented on May 12, 2024

PCNTL should only be used in the CLI.

Per the docs:

Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.

The behavior you are experiencing is because the process you are forking is the php-fpm process...which is always going to cause weird things to happen.

from fork.

dhrrgn avatar dhrrgn commented on May 12, 2024

@freekmurze May be worth adding a note in the README about this. Maybe even add a check like:

if (php_sapi_name() !== 'cli') {
    throw new RuntimeException('Process forking is only supported in CLI mode');
}

from fork.

lukeraymonddowning avatar lukeraymonddowning commented on May 12, 2024

Doh! Sorry about this 🤦🏼‍♂️ Thanks for the info!

from fork.

freekmurze avatar freekmurze commented on May 12, 2024

We should definitely mention in the readme that it doesn't word in a web context.
I'm a bit torn what we should do when this code is executed in a web context: throw an exception like suggested or above, or silently execute all given closures without concurrency.

@brendt What do you think?

from fork.

brendt avatar brendt commented on May 12, 2024

Definitely throw an exception :) I'll make the necessary changes.

from fork.

brendt avatar brendt commented on May 12, 2024

Done: https://github.com/spatie/fork/releases/tag/1.0.1

from fork.

jasonvarga avatar jasonvarga commented on May 12, 2024

Sorry to comment on a closed issue.

function_exists('pcntl_fork') returns true in my browser. (At least, when using Valet)

6c4c56c

from fork.

Related Issues (7)

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.