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

Compilation causing cache errors with version 7 and 8 #211

Open
novotnyjakub opened this issue Jun 29, 2021 · 1 comment
Open

Compilation causing cache errors with version 7 and 8 #211

novotnyjakub opened this issue Jun 29, 2021 · 1 comment

Comments

@novotnyjakub
Copy link

We noticed in our projects, that when upgrading the package to version 7 (and later 8), we started to have intermittent issues when compiling production assets on CI:

image

This is not at all problem with version 6 and so the solution for us has been to downgrade back to it.

We spent some time trying to identify the problem and noticed that the way the Elm compiler is used has changed in version 7. The compile method is now used instead of compileToString (

compiler = elmCompiler.compile(sources, options);
) which seems the only significant downstream change.

What we are wondering is whether other have the same issue and if it would be worth having the option to use synchronous compilation, perhaps optionally?

@joshuanianji
Copy link

joshuanianji commented Dec 9, 2021

I haven't tried the previous versions, but I do get the same errors when importing multiple Elm files into the same entry .js file for version 8. Here's a example:

import { Elm as Elm1 } from './Module1.elm';
import { Elm as Elm2 } from './Module2.elm';

window.addEventListener('load', () => {
    const node1 = document.getElementById('id1');
    Elm1.Module1.init({ node: node1 });

    const node2 = document.getElementById('id2');
    Elm2.Module2.init({ node: node2 });
})

Here's the output (I'm using yarn):

➤ YN0000: +-------------------------------------------------------------------------------
➤ YN0000: |  Corrupt File: /Users/runner/work/<path/to/elm-stuff>/0.19.1/o.dat
➤ YN0000: |   Byte Offset: 593610
➤ YN0000: |       Message: not enough bytes
➤ YN0000: |
➤ YN0000: | Please report this to https://github.com/elm/compiler/issues
➤ YN0000: | Trying to continue anyway.
➤ YN0000: +-------------------------------------------------------------------------------
➤ YN0000: 
➤ YN0000: -- CORRUPT CACHE ---------------------------------------------------------------
➤ YN0000: 
➤ YN0000: It looks like some of the information cached in elm-stuff/ has been corrupted.
➤ YN0000: 
➤ YN0000: Try deleting your elm-stuff/ directory to get unstuck.

Not sure if you have the same setup since I would assume importing two Elm modules is fairly uncommon, but my project required it nonetheless. Since this was a race condition for me, it only happened occasionally, and only on Github Actions (it seems to work fine on my own computer).

I looked around and saw that there was already a solution on Elm's Snowpack plugin that uses locks to guarantee sequential compilation. Looking at the code, I would assume it wouldn't be too difficult to implement here, if the library authors wanted.

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

No branches or pull requests

2 participants