Skip to content

Commit e9c2ed0

Browse files
committed
Make codegenScript handle invocations via async <<__Entrypoint>>s
If no script is provided, we were inferring it from the last entry in the backtrace. If you are using async `<<__Entrypoint>>`, the first entry in the call stack is in systemlib, in enterasyncentrypoint. - systemlib doesn't have file names in backtraces as they're considered builtin. This caused the crash - even if it did, it would be the wrong file name So, choose the last thing with a filename.
1 parent 00b958e commit e9c2ed0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/CodegenFactoryTrait.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,11 @@ final public function codegenGeneratedFromScript(
202202
?string $script = null,
203203
): CodegenGeneratedFrom {
204204
if ($script === null) {
205-
$trace = \debug_backtrace();
206-
$last = C\lastx($trace);
205+
$last = \debug_backtrace()
206+
|> Vec\filter($$, $frame ==> C\contains_key($frame, 'file'))
207+
|> C\last($$);
207208
invariant(
208-
$last !== false,
209+
$last !== null,
209210
"Couldn't get the strack trace. Please pass the script name to ".
210211
"codegenGeneratedFromScript",
211212
);

0 commit comments

Comments
 (0)