Received this error. For some additional info, I am only using the std/path module and some function from the Deno global.
thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/cell.rs:878:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1063
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:470
11: rust_begin_unwind
at src/libstd/panicking.rs:378
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
13: core::option::expect_none_failed
at src/libcore/option.rs:1211
14: deno_core::bindings::send
15: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
16: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
17: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
18: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
19: Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
Aborted
Duplicate of #6053
Maybe not duplicate of #6053
@denjucks Can you please provide an example code ?
Same command as #6053 with bash/lss
john@LAPP:/mnt/c/workspace$ RUST_BACKTRACE=1 /home/john/.deno/bin/deno
Deno 1.0.4
exit using ctrl+d or close()
> crypto.getRandomValues(new Uint8Array(10))
thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/cell.rs:878:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1063
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:470
11: rust_begin_unwind
at src/libstd/panicking.rs:378
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
13: core::option::expect_none_failed
at src/libcore/option.rs:1211
14: deno_core::bindings::send
15: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
16: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
17: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
18: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
19: Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
Aborted (core dumped)
john@LAPP:/mnt/c/workspace$
seems to be the same error
@hastri That was fixed in #6053
I'm interested in @denjucks's example code - which sounds unrelated to the REPL?
Seeing a similar issue on AWS Lambda. Can provide the runtime code if you need.
START RequestId: 40e01d08-1921-46fa-91ec-bf299d4d2774 Version: $LATEST
thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/cell.rs:878:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
/opt/bootstrap: line 3: 9 Aborted (core dumped) DENO_DIR=/tmp/deno_dir deno run -A --unstable /opt/runtime.ts
END RequestId: 40e01d08-1921-46fa-91ec-bf299d4d2774
REPORT RequestId: 40e01d08-1921-46fa-91ec-bf299d4d2774 Duration: 375.07 ms Billed Duration: 400 ms Memory Size: 128 MB Max Memory Used: 13 MB
@brianleroux Yes please provide some sample code so I can debug
Custom runtime here: https://begin-deno-runtime.s3-us-west-1.amazonaws.com/deno-1.0.4.zip
Effectively AWS Lambda calls bootstrap which is just DENO_DIR=/tmp/deno_dir deno run -A --unstable /opt/runtime.ts
The handler code imported by runtime.ts to get this behavior was:
export async function handler() {
return { ok: true };
};
// runtime.ts
// coldstart here
let env = Deno.env.toObject();
let api = env.AWS_LAMBDA_RUNTIME_API;
let name = env._HANDLER.split(".")[0];
let method = env._HANDLER.split(".")[1];
let invoke = `http://${api}/2018-06-01/runtime/invocation`;
let error = `http://${api}/2018-06-01/runtime/init/error`;
// look for index.{js,ts,tsx} and fallback to mod.{js,ts,tsx}
let paths = [
`${env.LAMBDA_TASK_ROOT}/index.js`,
`${env.LAMBDA_TASK_ROOT}/mod.js`,
`${env.LAMBDA_TASK_ROOT}/index.ts`,
`${env.LAMBDA_TASK_ROOT}/mod.ts`,
`${env.LAMBDA_TASK_ROOT}/index.tsx`,
`${env.LAMBDA_TASK_ROOT}/mod.tsx`,
];
// get the handler entry file
let found = false;
let handler;
for (let path of paths) {
found = await exists(path);
if (found) {
let mod = await import(path);
handler = mod[method];
if (typeof handler != "function") {
found = false;
} else {
break;
}
}
}
// if entry file is missing or invalid bail hard with a meaningful error
if (found === false) {
await post(error, {
errorType: "HandlerNotFound",
errorMessage:
`expected one of mod.js, mod.ts, mod.tsx, index.js, index.ts, or index.tsx to export a function named "${method}"`,
});
Deno.exit(1);
}
// all good! start the event loop
while (true) {
let { event, context } = await next(`${invoke}/next`);
try {
// invoke the handler
const payload = await handler(event, context);
await post(`${invoke}/${context.awsRequestId}/response`, payload);
} catch (err) {
// ensure errors bubble
await post(`${invoke}/${context.awsRequestId}/error`, {
errorType: err.name,
errorMessage: err.message,
stackTrace: err.stack,
});
}
}
/** helper to get next invocation */
async function next(url: string) {
let env = Deno.env.toObject();
let req = await fetch(url);
let reqID = req.headers.get("Lambda-Runtime-Aws-Request-Id");
let arn = req.headers.get("lambda-runtime-invoked-function-arn");
let event = await req.json();
let context = {
awsRequestId: reqID,
invokedFunctionArn: arn,
logGroupName: env.AWS_LAMBDA_LOG_GROUP_NAME,
logStreamName: env.AWS_LAMBDA_LOG_STREAM_NAME,
functionName: env.AWS_LAMBDA_FUNCTION_NAME,
functionVersion: env.AWS_LAMBDA_FUNCTION_VERSION,
memoryLimitInMB: env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE,
};
return { event, context };
}
/** helper to post message to lambda */
async function post(url: string, payload: object) {
let result = await fetch(url, {
method: "POST",
body: JSON.stringify(payload),
});
await result.blob();
}
/** helper to check for the entry file */
async function exists(filename: string): Promise<boolean> {
try {
await Deno.stat(filename);
return true;
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
return false;
} else {
throw error;
}
}
}
Thanks @brianleroux but I'm still unable to repeat the failure.
If anyone can provide some small sample code that demonstrates this failure, that would be very helpful.
Once we figure out this issue, I'll be cutting a new release v1.0.5
I'm def reproducing (tho perhaps I compiled the binary wrong?) Reran with RUST_BACKTRACE=1 and got the following output:
START RequestId: a7ae7ed8-4d24-4b80-b037-8b7accd63ec7 Version: $LATEST
thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libcore/cell.rs:878:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1063
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1426
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:204
9: std::panicking::default_hook
at src/libstd/panicking.rs:224
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:470
11: rust_begin_unwind
at src/libstd/panicking.rs:378
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
13: core::option::expect_none_failed
at src/libcore/option.rs:1211
14: deno_core::bindings::send
15: <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn
16: _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
17: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
18: _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
19: Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
/opt/bootstrap: line 3: 9 Aborted (core dumped) DENO_DIR=/tmp/deno_dir RUST_BACKTRACE=1 deno run -A --unstable /opt/runtime.ts
END RequestId: a7ae7ed8-4d24-4b80-b037-8b7accd63ec7
REPORT RequestId: a7ae7ed8-4d24-4b80-b037-8b7accd63ec7 Duration: 2543.13 ms Billed Duration: 2600 ms Memory Size: 128 MB Max Memory Used: 70 MB
RequestId: a7ae7ed8-4d24-4b80-b037-8b7accd63ec7 Error: Runtime exited with error: exit status 134
Runtime.ExitError
@ry
// a.js
await import(new URL("./b.js", import.meta.url).toString());
const conn = Deno.connect({hostname: "localhost", port: 8080});
// b.js
// (empty)
https://github.com/xcatliu/pagic/issues/22
await import(new URL('./b.js', import.meta.url).toString());
const watcher = Deno.watchFs('.');
The problem is due to await in dynamic import, see https://github.com/denoland/deno/issues/6071#issuecomment-638298318
v1.0.5 will be released later today with a fix for this
confirmed fixed! thank u 馃嵒
@ry Repro when using debug mode in vscode (but only when import https://dev.jspm.io/[email protected]):
// a.ts
import * as ts from 'https://dev.jspm.io/[email protected]';
console.log(ts.default.transpileModule('const foo: number = 1;', {}).outputText);
Above code works fine in normal deno:
$ deno --version
deno 1.1.0
v8 8.4.300
typescript 3.9.2
$ deno run -A a.ts
var foo = 1;
However, it throws error when debug in vscode:
/Users/xcatliu/.deno/bin/deno run --inspect-brk -A a.ts
Debugger listening on ws://127.0.0.1:9229/ws/118bc875-11b7-43b2-8b0a-30baa323b8ad
Debugger session started.
thread 'main' panicked at 'already borrowed: BorrowMutError', /rustc/49cae55760da0a43428eba73abcb659bb70cf2e4/src/libcore/cell.rs:878:9
stack backtrace:
0: 0x110d7e9bf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d53b696ac99295
1: 0x110daadfe - core::fmt::write::hf81c429634e1f3ed
2: 0x110d75917 - std::io::Write::write_fmt::had2a3b01a2c037b5
3: 0x110d8100a - std::panicking::default_hook::{{closure}}::ha991e4eca34b4afa
4: 0x110d80d4c - std::panicking::default_hook::h722aa3f5c1c31788
5: 0x110d815d8 - std::panicking::rust_panic_with_hook::h2cd47f71d6d55501
6: 0x110d811a2 - rust_begin_unwind
7: 0x110dd595f - core::panicking::panic_fmt::h299f54c72477a62a
8: 0x110dd5865 - core::result::unwrap_failed::hf7a9e1e19e331f17
9: 0x1101dd1c6 - deno_core::bindings::send::h9bde1f22d54f964b
10: 0x1101bf4ad - <extern "C" fn(A0) .> R as rusty_v8::support::CFnFrom<F>>::mapping::c_fn::h184c60d18e8b8431
11: 0x11025eb4f - _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
12: 0x11025e061 - _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
13: 0x11025d6d1 - _ZN2v88internalL26Builtin_Impl_HandleApiCallENS0_16BuiltinArgumentsEPNS0_7IsolateE
fatal runtime error: failed to initiate panic, error 5
The launch.json config:
{
"version": "0.2.0",
"configurations": [
{
"env": {
"RUST_BACKTRACE": "full"
},
"name": "Deno",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "a.ts"],
"port": 9229
}
]
}
VSCode Version: 1.46.0
@xcatliu I can't repeat and it is very likely unrelated to this issue. Please open a new issue and provide an example of a crash from the command-line (not vs code) and I will gladly debug it for you.
Please open a new issue and provide an example of a crash from the command-line (not vs code)
@ry The point is, command-line works fine but vscode debug throws error 馃槬
// a.ts
import * as ts from 'https://dev.jspm.io/[email protected]';
console.log(ts.default.transpileModule('const foo: number = 1;', {}).outputText);
@xcatliu Yes I was unable to repeat in vscode... but to be honest I'm not very familiar with it. Please open a new issue and describe the problem again. I'm relatively certain it's the same error message but not the same as this one.
Most helpful comment
v1.0.5 will be released later today with a fix for this