Skip to content

Executable compiled with --include fails to load included files, results in memory leak #27001

@raucao

Description

@raucao

Version: Deno 2.1.1

I tried to embed my asset file directory as described in https://deno.com/blog/v2.1#embed-assets-files-in-deno-compile by adjusting my build command like this:

deno compile --allow-all --include ./assets/ --output substr server.ts

My application is using oak's send function like so (with irrelevant code removed):

import { Application, Router, send } from "@oak/oak";
const router = new Router();

router.get("/assets/:path*", async (ctx) => {
  try {
    let filePath = ctx.params.path || "";
    let root: string;
    root = `${import.meta.dirname}/assets`;
    await send(ctx, filePath, { root });
  } catch (e) {
    console.error(e);
  }
});

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

await app.listen({ port: 8000 });

The HTTP client fetches e.g. /assets/css/layout.css from the server. This works as intended (and as it did before) with deno run. However, with the compiled executable, the send function silently fails to load the file (no logs), and instead results in a memory leak, which grows to eat up all available memory on the machine.

I tried to strace the process, and the output doesn't seem to contain any file open or read calls. Here's a snippet of what it mostly contains:

brk(0x559427519000)                     = 0x559427519000                                                                                                                                      
brk(0x55942753a000)                     = 0x55942753a000                                                                                                                                      
epoll_wait(3, [], 1024, 0)              = 0                                                                                                                                                   
brk(0x55942755b000)                     = 0x55942755b000                                                                                                                                      
brk(0x559427580000)                     = 0x559427580000                                                                                                                                      
brk(0x5594275a5000)                     = 0x5594275a5000                                                                                                                                      
epoll_wait(3, [], 1024, 0)              = 0                                                                                                                                                   
brk(0x5594275ca000)                     = 0x5594275ca000                                                                                                                                      
brk(0x5594275ef000)                     = 0x5594275ef000                                                                                                                                      
epoll_wait(3, [], 1024, 0)              = 0                                                                                                                                                   
brk(0x559427613000)                     = 0x559427613000                                                                                                                                      
brk(0x559427634000)                     = 0x559427634000                                                                                                                                      
epoll_wait(3, [], 1024, 0)              = 0                                                                                                                                                   
brk(0x559427655000)                     = 0x559427655000                                                                                                                                      
brk(0x559427676000)                     = 0x559427676000                                                                                                                                      
brk(0x559427697000)                     = 0x559427697000                                                                                                                                      
epoll_wait(3, [], 1024, 0)              = 0                                                                                                                                                   
futex(0x5593459e75f0, FUTEX_WAKE_PRIVATE, 2147483647) = 1                                                                                                                                     
futex(0x5593459e8014, FUTEX_WAKE_PRIVATE, 2147483647) = 1                                                                                                                                     
futex(0x5593459e7e60, FUTEX_WAKE_PRIVATE, 2147483647) = 1                                                                                                                                     
futex(0x5593459e68c8, FUTEX_WAKE_PRIVATE, 1) = 1                                                                                                                                              
futex(0x5593459e81c4, FUTEX_WAKE_PRIVATE, 2147483647) = 1                                                                                                                                     
futex(0x5593459e68c8, FUTEX_WAKE_PRIVATE, 1) = 1                                                                                                                                              
futex(0x5593459e7e64, FUTEX_WAKE_PRIVATE, 2147483647) = 0                                                                                                                                     
futex(0x5593459e68c8, FUTEX_WAKE_PRIVATE, 1) = 1                                                                                                                                              
futex(0x559427693a98, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Resource temporarily unavailable)                                         
futex(0x559427693a20, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x5593459e77a4, FUTEX_WAKE_PRIVATE, 2147483647) = 1
getpid()                                = 646905
brk(0x5594276b8000)                     = 0x5594276b8000
brk(0x5594276d9000)                     = 0x5594276d9000
futex(0x5593459e77a0, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x5593459e7950, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x5593459e68c8, FUTEX_WAKE_PRIVATE, 1) = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlycompilerelated to the `deno compile` feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions