You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone.
Hopefully someone can see what I'm doing wrong here, and let me know how to get this to work...
The following code works if run on system where isSupported() returns false, but fails on systems where isSupported() returns true.
$pool->add(function () use ($url, $context) {
// Request the file
$output = @file_get_contents($url, false, $context);
if($output) {
$output = trim($output);
}
return $output;
})->then(function ($output) use ($addon, &$version_info) {
if (!$output) {
return false;
}
// Clean up data returned
return json_decode($output, true));
})->catch(function (Throwable $exception) {
// Handle exception
return false;
});
$pool->wait();
Putting a debugger on this indicates that the $pool->add() step is run, but the ->then() and ->catch() steps are never called when async is supported. When not supported, the steps in add() and then() are executed serially.
Separately I have confirmed that the @file_get_contents() step returns data with the values of $url and $context provided.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone.
Hopefully someone can see what I'm doing wrong here, and let me know how to get this to work...
The following code works if run on system where
isSupported()
returns false, but fails on systems whereisSupported()
returns true.Putting a debugger on this indicates that the
$pool->add()
step is run, but the->then()
and->catch()
steps are never called when async is supported. When not supported, the steps inadd()
andthen()
are executed serially.Separately I have confirmed that the
@file_get_contents()
step returns data with the values of$url
and$context
provided.Thanks in advance for any help anyone can offer.
Beta Was this translation helpful? Give feedback.
All reactions