Skip to content

Remove the esm loader and install yarn in the Docker build - #74

Merged
SleeplessByte merged 3 commits into
mainfrom
remove-esm-loader
Nov 18, 2026
Merged

SleeplessByte merged 3 commits into
mainfrom
remove-esm-loader

Conversation

@iHiD

@iHiD iHiD commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

This PR was opened by Claude, an AI assistant working on iHiD's behalf.

What was broken

Every representer job in production fails. The tooling invoker logs each one as status 513, so no representations are made. The invoker's logs go back 3.5 days, and every job in that period failed.

There are two separate problems:

  1. bin/run.sh runs node -r esm -r module-alias/register ./dist/represent.js. The esm package (unmaintained since 2019) crashes on current Node versions, so the representer exits with status 1 before it does any work.
  2. The node:lts-alpine base tag now points to Node 26, which ships without yarn, so yarn install fails and the image can't be built. The Deploy run for Update pr.ci.js.yml #72 on 13 November failed at this step.

Evidence

The production image (exercism/javascript-representer:latest, built on 22 September, Node v24.21.0) fails when run on the two-fer fixture. It writes 65 KB of minified esm.js source to stderr and exits with 1. With an uncaughtException handler loaded first, the error is:

TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
    /opt/representer/node_modules/module-alias/register.js:1

I ran the same dist folder with -r esm on Node 22.22.0, 24.0.0, 24.10.0, 24.18.0 and 24.21.0, and it failed on all of them. Without -r esm, the same production image on Node 24.21.0 produces representation.txt and mapping.json that match the fixture's expected files.

The TypeScript build already outputs CommonJS ("module": "CommonJs" in tsconfig.json), so esm has nothing to do.

Fix

  • This PR removes -r esm from every script in bin/ and from src/remote-represent.ts, and removes esm from package.json and yarn.lock.
  • It pins both FROM lines to node:26-alpine3.24@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5, the current node:lts-alpine digest.
  • It installs yarn with npm install -g yarn in the builder stage, because that image has no yarn and no corepack, and package.json has no packageManager field.

Verification

  • bin/run-tests-in-docker.sh builds the image and passes.
  • I ran the built image (Node 26.13.1, yarn 1.22.22) the way the tooling invoker does: one directory mounted at /mnt/exercism-iteration, the arguments two-fer /mnt/exercism-iteration/ /mnt/exercism-iteration/, with --network none --read-only. The container exited with 0, and representation.txt and mapping.json match the expected files.
  • yarn install --frozen-lockfile succeeds with yarn 1.22.22 on Node 26.13.1, and Prettier 2.7.1 passes on the changed files.

After merging

The Deploy workflow will build the image and push it to ECR with the production tag, which the tooling invoker runs. Representer jobs should then succeed.

🤖 Generated with Claude Code

The esm package crashes on Node 24 with "TypeError: Function.prototype.apply
was called on undefined" while loading module-alias/register, so every
representer run exits with status 1. The TypeScript build outputs CommonJS,
so esm has nothing to do and can go.

The node:lts-alpine tag now points to Node 26, which ships without yarn,
so the image no longer builds. Pin the base image to the same Node 24
digest used by the analyzers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iHiD
iHiD requested a review from a team as a code owner November 17, 2026 11:47
@iHiD
iHiD requested a review from SleeplessByte November 17, 2026 13:28
@SleeplessByte

Copy link
Copy Markdown
Member

This should not pin version 24 and instead fix the build by downloading yarn or something like that.

The Node 26 image has no yarn and no corepack, so install yarn with npm
in the builder stage and keep the base image on node:lts-alpine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iHiD iHiD changed the title Remove the esm loader and pin the Node base image Remove the esm loader and install yarn in the Docker build Nov 18, 2026
@iHiD

iHiD commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

This reply is from Claude, an AI assistant working on iHiD's behalf.

Node is no longer pinned. The Dockerfile uses node:lts-alpine again and installs yarn with npm install -g yarn in the builder stage, because the Node 26 image has neither yarn nor corepack and package.json has no packageManager field. I built the image on Node 26.13.1 with yarn 1.22.22. bin/run-tests-in-docker.sh passes, yarn install --frozen-lockfile works, and a run on two-fer with the tooling invoker's arguments produced the expected representation.txt and mapping.json. exercism/typescript-representer#31 has the same change.

Comment thread Dockerfile Outdated
@@ -1,9 +1,11 @@
# sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd => node:24.18.0-alpine3.24
FROM node:lts-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd as builder
FROM node:lts-alpine as builder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want pinned hashes in general so different runners can share a common base.

node:lts-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd looks to be the most commonly used hash across runners at the moment. With !75 dependabot will open version bumps as needed.

@iHiD

iHiD commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

This comment is from Claude, an AI assistant working on iHiD's behalf.

@SleeplessByte, would you rather these representers run on Node 24 or Node 26?

We'd like every tool to share the same pinned Node base image, because a shared base makes the tooling machines boot much faster. The digest that @IsaacG suggested (node:lts-alpine@sha256:a0b9bf06…) is the one most runners use today, and it's Node 24.18.0, which already includes yarn. If you'd prefer Node 26, we'll pin a Node 26 digest here, and that digest would ideally become the shared base for the other runners too.

Both work with this PR's fix. Once you choose, I'll update this PR and exercism/typescript-representer#31 to match.

@IsaacG

IsaacG commented Nov 18, 2026

Copy link
Copy Markdown
Member

The latest hash of node:lts-alpine is node:26-alpine3.24@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5

We can use that across node:lts-alpine images as the latest version.

@SleeplessByte

Copy link
Copy Markdown
Member

Yes. Use the latest hash Isaac suggested. That's what I've also always done. In this repo we use lts, whatever is latest.

Both stages now use node:26-alpine3.24 by digest, the current node:lts-alpine image. That image has no yarn, so the builder stage still installs it with npm.

Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com>
@exercism-agent

Copy link
Copy Markdown

This comment is from Claude, an AI assistant working on iHiD's behalf.

Thanks, @SleeplessByte and @IsaacG. Both this PR and exercism/typescript-representer#31 are now pinned to that digest, and the smoke tests pass on both.

@SleeplessByte
SleeplessByte merged commit ab3fbb6 into main Nov 18, 2026
6 checks passed
@SleeplessByte
SleeplessByte deleted the remove-esm-loader branch November 18, 2026 11:29
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 this pull request may close these issues.

3 participants