Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: Crash on Windows #786

Closed
ElDynamo opened this issue May 3, 2023 · 8 comments · Fixed by #791
Closed

🐛 BUG: Crash on Windows #786

ElDynamo opened this issue May 3, 2023 · 8 comments · Fixed by #791

Comments

@ElDynamo
Copy link

ElDynamo commented May 3, 2023

What version of @astrojs/compiler are you using?

2.3.3

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

In component "List.astro" I get error:

PS C:\Users\thedy\Stronki projekty\betterize-project> npm run build

> [email protected] build
> astro build

12:47:13 [content] No content directory found. Skipping type generation.
12:47:13 [build] output target: static
12:47:13 [build] Collecting build info...
12:47:13 [build] Completed in 425ms.
12:47:13 [build] Building static entrypoints...
[astro:build] runtime error: index out of range [196] with length 196
file: C:/Users/thedy/Stronki projekty/betterize-project/src/components/editorjs/subcomponents/List.astro:undefined:undefined
 error   runtime error: index out of range [196] with length 196
  Hint:
    This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler.   
  File:
    C:/Users/thedy/Stronki projekty/betterize-project/src/components/editorjs/subcomponents/List.astro
  Stacktrace:
goroutine 53 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x6
github.com/withastro/compiler/internal_wasm/utils.ErrorToJSError(0x60f320, {0x1897958, 0x567848})
        github.com/withastro/compiler/internal_wasm/utils/utils.go:68 +0x2
main.Transform.func1.1.1.1()
        ./astro-wasm.go:284 +0x5
panic({0x2dae0, 0x567848})
        runtime/panic.go:884 +0x29
github.com/withastro/compiler/internal/printer.(*printer).printTextWithSourcemap(0x70f758, {0x512b60, 0xc4}, {0xd9})
        github.com/withastro/compiler/internal/printer/printer.go:72 +0x25
github.com/withastro/compiler/internal/printer.render1(0x70f758, 0x6f63c0, {0x0, 0x0, 0x4, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:320 +0x18f
github.com/withastro/compiler/internal/printer.render1(0x70f758, 0x6f6140, {0x0, 0x0, 0x3, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x70f758, 0x6f6000, {0x0, 0x0, 0x2, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x70f758, 0x6bdcc0, {0x0, 0x0, 0x1, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x70f758, 0x6bd900, {0x1, 0x0, 0x0, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:121 +0xc1
github.com/withastro/compiler/internal/printer.printToJs(0x70f758, 0x6bd900, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, {0x65f680, 0x31}, {0x567770, ...}, ...})
        github.com/withastro/compiler/internal/printer/print-to-js.go:72 +0x3
github.com/withastro/compiler/internal/printer.PrintToJS({0x5b4f00, 0x2fb}, 0x6bd900, 0x0, {{0x6b2c10, 0x8}, {0x6b4700, 0x62}, {0x65f680, 0x31}, ...}, ...)
        github.com/withastro/compiler/internal/printer/print-to-js.go:53 +0xc
main.Transform.func1.1.1()
        ./astro-wasm.go:401 +0x38
created by main.Transform.func1.1
        ./astro-wasm.go:280 +0x14

List.astro (code below)

---
enum Style {
    Ordered = "ordered",
    Unordered = "unordered",
}

interface Props {
    style: Style;
    items: [string];
}

const { style, items } = Astro.props;
console.log(items);
---

<div class="px-10">
    {
        () => {
            if (style == Style.Ordered) {
                return items.map((item: string, index: number) => (
                    // index + 1 is needed to start with 1 not 0
                    <p>
                        {index + 1}
                        <Fragment set:html={item} />
                    </p>
                ));
            } else {
                return items.map((item: string) => (
                    <Fragment set:html={item} />
                ));
            }
        }
    }
</div>

when I remove a line with comment:

 // index + 1 is needed to start with 1 not 0

then everything seems to work just fine

Warning!
Link below isn't a "minimal reproducible example".
The whole issue with code is described in this post

Link to Minimal Reproducible Example

https://www.thislinkdoesnotexist.com

@petterhoel
Copy link

petterhoel commented May 3, 2023

I am having the same issue. Fairly same anyways. It happens:

  • Every time on our build servers (Windows - several build agents see screenshots)
  • Randomly error or build success on my windows 11 work station
  • Not yet on my mac laptop (m1)

The randomness on my windows machine sort of feels like there is some kind race condition going on. I have spent some hours yesterday and most of today trying to detect a pattern. Trying to build many different commits in our repo, and three different Astro versions, but I am havent found anything predictable to trigger/not trigger the error on my work station. I have seen it triggered with Astro versions 2.3.0, 2.3.3 and 2.3.4.

node 16.17.0 for all environments
npm workspace/monorepo structure if that matters

image

@petterhoel
Copy link

Update: I think this hits us when we reinstall packages and the dependencies of our dependencies change. The diff in the entire package-lock.json is pretty huge, but I would think this version change is relevant (se screen shot). This commits breaks the build on our build server. Could this be a regression in the compiler?
image

@petterhoel
Copy link

Another update: This seems to be a windows only issue. I have tested on macs and linux (running the build on netlify) with no issues.

@maddsua
Copy link

maddsua commented May 7, 2023

In my case a pattern like this causes the issue
изображение

Worked OK on v2.3.1, crashes on 2.4.2

Stacktrace
goroutine 64 [running]:
runtime/debug.Stack()
  runtime/debug/stack.go:24 +0x6
github.com/withastro/compiler/internal_wasm/utils.ErrorToJSError(0x47a240, {0x1918040, 0x4864c8})
  github.com/withastro/compiler/internal_wasm/utils/utils.go:68 +0x2
main.Transform.func1.1.1.1()
  ./astro-wasm.go:284 +0x5
panic({0x2dae0, 0x4864c8})
  runtime/panic.go:884 +0x29
github.com/withastro/compiler/internal/printer.(*printer).printTextWithSourcemap(0x6a1758, {0x620b00, 0x3a}, {0x21a})
  github.com/withastro/compiler/internal/printer/printer.go:72 +0x25
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6df540, {0x0, 0x0, 0x5, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:320 +0x18f
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6dec80, {0x0, 0x0, 0x4, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6dea00, {0x0, 0x0, 0x3, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6de8c0, {0x0, 0x0, 0x2, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6de640, {0x0, 0x0, 0x1, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:696 +0x53d
github.com/withastro/compiler/internal/printer.render1(0x6a1758, 0x6de140, {0x1, 0x0, 0x0, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:121 +0xc1
github.com/withastro/compiler/internal/printer.printToJs(0x6a1758, 0x6de140, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, {0x6208c0, 0x33}, {0x486240, ...}, ...})
  github.com/withastro/compiler/internal/printer/print-to-js.go:72 +0x3
github.com/withastro/compiler/internal/printer.PrintToJS({0x5d7500, 0x1429}, 0x6de140, 0x1, {{0x5c0350, 0x8}, {0x4ae4b0, 0x45}, {0x6208c0, 0x33}, ...}, ...)
  github.com/withastro/compiler/internal/printer/print-to-js.go:53 +0xc
main.Transform.func1.1.1()
  ./astro-wasm.go:401 +0x38
created by main.Transform.func1.1
  ./astro-wasm.go:280 +0x14

@maddsua
Copy link

maddsua commented May 7, 2023

In my case a pattern like this causes the issue изображение

Worked OK on v2.3.1, crashes on 2.4.2

Very interesting... changing ....getTime() / 1000 to ....getTime() * 0.001 seems to help to avoid the bug.

Just to document for anyone who struggles with the issue, my solution for now:

image

I just moved this piece of logic to frontmatter, in this case it's no big deal

@TechAurelian2
Copy link

Another update: This seems to be a windows only issue. I have tested on macs and linux (running the build on netlify) with no issues.

Same here. Fails on a Windows 10 machine

runtime error: index out of range [96] with length 96
This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler.

but compiles OK to production on the Netlify servers using the Ubuntu Focal 20.04 build image

@SubratKumarGupta
Copy link

I am getting the same issue on wsl2 with Ubuntu and node v20.1.0, Astro 2.4.2,

    This is almost always a problem with the Astro compiler, not your code. Please open an issue at https://astro.build/issues/compiler.
  File:
    /mnt/c/Users/SUBRAT/Desktop/projects/subratgupta-portfolio/src/components/Sidebar/nav.astro 

this is the project https://github.com/SubratKumarGupta/subratgupta-portfolio

@maddsua
Copy link

maddsua commented May 9, 2023

Yes yes yes yes, it totally was due to CRLF line endings, I never thought about it, I just assumed that windows line endings shouldn't cause any issues (I'm a person, who uses all the opensource tools but still on windows 😂).

Than-Q, @Princesseuh !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants