denoland / deno_doc

Documentation generator for Deno
MIT License
261 stars 54 forks source link

RuntimeError: memory access out of bounds #326

Open devingfx opened 1 year ago

devingfx commented 1 year ago

Hi! I have got a low level wasm error that I can't understand.

Steps to reproduce:

deno.jsonc

{
    "imports": {
        "std/": "https://deno.land/std@0.177.0/"
    },
}

docs.js

import { doc } from "https://deno.land/x/deno_doc@0.58.0/mod.ts"
import { resolve, toFileUrl } from 'std/path/mod.ts'

console.log( toFileUrl(resolve('./Object/foo.js')) )
console.log( await doc(toFileUrl(resolve('./Object/foo.js'))) )

Object/foo.js


/**
 * Object/foo
 */
export default 42

Error:

dig@dig-terra:~/dev/some-project$ deno run -A docs.js 
URL {
  href: "file:///home/dig/dev/some-project/Object/foo.js",
  origin: "null",
  protocol: "file:",
  username: "",
  password: "",
  host: "",
  hostname: "",
  port: "",
  pathname: "/home/dig/dev/some-project/Object/foo.js",
  hash: "",
  search: ""
}
error: Uncaught (in promise) RuntimeError: memory access out of bounds
    at <anonymous> (https://deno.land/x/deno_doc@0.58.0/lib/deno_doc_bg.wasm:1:2007454)
    at <anonymous> (https://deno.land/x/deno_doc@0.58.0/lib/deno_doc_bg.wasm:1:1967225)
    at <anonymous> (https://deno.land/x/deno_doc@0.58.0/lib/deno_doc_bg.wasm:1:1955069)
    at passStringToWasm0 (https://deno.land/x/deno_doc@0.58.0/lib/deno_doc.generated.js:79:11)
    at Object.doc (https://deno.land/x/deno_doc@0.58.0/lib/deno_doc.generated.js:230:16)
    at doc (https://deno.land/x/deno_doc@0.58.0/mod.ts:81:15)
    at async file:///home/dig/dev/some-project/docs.js:6:14

Mainwhile deno doc is working perfectly!

dig@dig-terra:~/dev/some-project$ deno doc Object/foo.js 
Defined in file:///home/dig/dev/some-project/Object/foo.js:5:0

var default: 42
  Object/foo
oscarotero commented 1 year ago

I have the same error with this code:

import { doc } from "https://deno.land/x/deno_doc@0.65.0/mod.ts";

const docs = await doc("https://deno.land/x/lume@v1.18.4/plugins/esbuild.ts", {
  includeAll: true,
});

It doesn't fail if the includeAll option is false.

kt3k commented 1 year ago

@devingfx What happens if you change the below:

console.log( await doc(toFileUrl(resolve('./Object/foo.js'))) )

to

console.log( await doc(toFileUrl(resolve('./Object/foo.js')).href) )