Download built image from railway or ssh access to service.

spread-admin
HOBBY

a year ago

Hey folks. I'm debugging an issue with my deployment and it would really help if there was a way to have ssh access to my service or to download the docker image and run some commands on it. Is that something that's possible?

My issue is with the following package https://github.com/cloudflare/html-rewriter-wasm
Locally it works but I think that due to how its built the following line messes with the bundler:

const { awaitPromise, setWasmExports, wrap } = require(String.raw`./asyncify.js`);

and asyncify.js is missing from the end bundle which causes the following error on my deployed service:

⨯ Error: Cannot find module './asyncify.js'

I verified that by using patch-packages and on my locally built docker the file is now present, however the issue persists on the railway built and deployed

Would appreciate any help on this 🙂

0 Replies

spread-admin
HOBBY

a year ago

Project id: b880d42a-b80e-4f1e-b8f1-75cdd868eef0


a year ago

is asyncify.js a file you have in your project?


spread-admin
HOBBY

a year ago

It's a part of the html-rewriter-wasm package


spread-admin
HOBBY

a year ago

1233489910938337300


a year ago

are you using nixpacks?


spread-admin
HOBBY

a year ago

but I think that weird require statement is messing up the nextjs bundler and on my built docker image I only see htmlrewriter.js and htmlrewriter_bg.wasm unless I replace that require line using patch-packages


spread-admin
HOBBY

a year ago

Using regular dockerfile to build. Wasn't able to port to nixpacks yet


a year ago

and you have built and ran an image from this dockerfile locally?


spread-admin
HOBBY

a year ago

Yeah


spread-admin
HOBBY

a year ago

Basically added a patch file:

-const { awaitPromise, setWasmExports, wrap } = require(String.raw`./asyncify.js`);
+const { awaitPromise, setWasmExports, wrap } = require('./asyncify.js');

spread-admin
HOBBY

a year ago

Then when I rebuild locally I do get the asyncify.js to be a part of the final docker image


spread-admin
HOBBY

a year ago

My hunch is that the patch isnt applied while building on railway, to verify that I'd need to access to end image and review the file system, hence my request above 🙂


a year ago

specifically built an image, not simply ran npm run build?


spread-admin
HOBBY

a year ago

Yeah docker build and all


a year ago

railway uses buildx and I assume you aren't but that really shouldn't matter


spread-admin
HOBBY

a year ago

Hm, I can try that locally


spread-admin
HOBBY

a year ago

Building with COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 should know shortly if its any different


a year ago

sounds good


spread-admin
HOBBY

a year ago

Yep still looks good with buildx


spread-admin
HOBBY

a year ago

docker run --rm -it --entrypoint /bin/sh test-service
/app $ ls /app/node_modules/html-rewriter-wasm/dist/
asyncify.js            html_rewriter.js       html_rewriter_bg.wasm

spread-admin
HOBBY

a year ago

(and just to re-iterate, if I don't use the patch above, the asyncify.js file doesn't exist, which casues the "cannot find module" error above)


a year ago

say you did have ssh and you logged in and saw that there was no asyncify.js file in the /node_modules/html-rewriter-wasm/dist/ folder, what would you do then?


spread-admin
HOBBY

a year ago

Basically run the command above and check if asyncify.js is there or not. If it's not then I know my patch isn't being applied, if it is then I'd have to go back to the drawing board 😅


a year ago

and if the file wasn't there, what would you do