vwkd
vwkd
DDeno
Created by vwkd on 7/29/2024 in #help
Streaming download throws `Bad resource ID`
Anyone have an idea why this errors when closing the file even though the download was successfully written to the file? deno 1.45.2
const res = await fetch(url);

if (!res.ok) {
throw new Error(`Got error ${res.status} ${res.statusText}`);
}

const body = res.body;

if (!body) {
throw new Error(`Got no body`);
}

const file = await Deno.create(path);

try {
await body.pipeTo(file.writable);
} catch (e) {
await Deno.remove(path);
throw new Error(`Download interrupted ${e}`);
} finally {
file.close();
}
const res = await fetch(url);

if (!res.ok) {
throw new Error(`Got error ${res.status} ${res.statusText}`);
}

const body = res.body;

if (!body) {
throw new Error(`Got no body`);
}

const file = await Deno.create(path);

try {
await body.pipeTo(file.writable);
} catch (e) {
await Deno.remove(path);
throw new Error(`Download interrupted ${e}`);
} finally {
file.close();
}
error: Uncaught (in promise) BadResource: Bad resource ID
file.close();
^
at FsFile.close (ext:deno_fs/30_fs.js:743:10)
at loadFile (file:///foobar/loadFile.ts:142:16)
at eventLoopTick (ext:core/01_core.js:168:7)
at async file:///foobar/main.ts:42:7
error: Uncaught (in promise) BadResource: Bad resource ID
file.close();
^
at FsFile.close (ext:deno_fs/30_fs.js:743:10)
at loadFile (file:///foobar/loadFile.ts:142:16)
at eventLoopTick (ext:core/01_core.js:168:7)
at async file:///foobar/main.ts:42:7
4 replies
DDeno
Created by vwkd on 2/19/2024 in #help
Interactive Jupyter notebook
Has anyone figured out how to do interactivity in a Jupyter notebook with Deno kernel in VSCode? Like showing a graphical user input like a slider and hooking it up to change something else like a plot.
2 replies
DDeno
Created by vwkd on 2/14/2024 in #help
How to unset white background of SVG in Jupyter notebook?
I’ve got a Jupyter notebook with Deno kernel in VSCode that displays an SVG. The SVG has a forced white background which doesn’t play well with dark mode. Digging through the dev tools shows it’s caused by a rule referencing a wrapping div.
.svgContainerStyle svg {
background-color: white;
}
.svgContainerStyle svg {
background-color: white;
}
So, it can’t be the SVG itself. Maybe Deno? Maybe Jupyter fronted? Maybe some of their VSCode extensions? How can I unset the background color of the SVG?
3 replies
DDeno
Created by vwkd on 4/23/2023 in #help
Empty output in Deno.Command
I’m trying to run the command git log —grep='.' from Deno. However, it always returns an empty output. If I delete the grep option it returns it fine. Running the same command from the CLI returns all commits. It’s weird because other “similarly looking options” seem to work fine for example —format.
const command = new Deno.Command("git", { args: [
"log",
// grep seems make problems
"--grep='.'",
// "--format='%h %s'",
]});
const { code, stdout, stderr } = await command.output();
console.log(code)
console.log(new TextDecoder().decode(stdout))
console.log(new TextDecoder().decode(stderr))
const command = new Deno.Command("git", { args: [
"log",
// grep seems make problems
"--grep='.'",
// "--format='%h %s'",
]});
const { code, stdout, stderr } = await command.output();
console.log(code)
console.log(new TextDecoder().decode(stdout))
console.log(new TextDecoder().decode(stderr))
4 replies
DDeno
Created by vwkd on 10/19/2022 in #help
Sync uuid from string
How can I generate a UUID from a string synchronously? In the standard library I only found this async module https://deno.land/std@0.160.0/uuid/v5.ts?s=generate
6 replies