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

import_map causes module not found #179

Open
kyeotic opened this issue May 30, 2022 · 4 comments
Open

import_map causes module not found #179

kyeotic opened this issue May 30, 2022 · 4 comments

Comments

@kyeotic
Copy link

kyeotic commented May 30, 2022

I have an otherwise working application that fails if I try to use an import map; specifically the kind of import maps generated by trex. I have created a minimal repro of the issue with this repository. Here is the working version without the import map.

The failure it produces is

2022-05-30T13:22:56.089-07:00 | error: Module not found "file:///var/task/tmp/runtime.js".
-- | --
  | 2022-05-30T13:22:56.133-07:00 | error: deno exited
  | 2022-05-30T13:22:56.219-07:00 | START RequestId: ee82b3a3-6dc4-4f7b-ae89-d7646649862d Version: $LATEST
  | 2022-05-30T13:22:56.822-07:00 | error: Module not found "file:///var/task/tmp/runtime.js".
  | 2022-05-30T13:22:57.303-07:00 | error: deno exited
  | 2022-05-30T13:22:57.443-07:00 | END RequestId: ee82b3a3-6dc4-4f7b-ae89-d7646649862d
  | 2022-05-30T13:22:57.443-07:00 | REPORT RequestId: ee82b3a3-6dc4-4f7b-ae89-d7646649862d Duration: 1222.96 ms Billed Duration: 1223 ms Memory Size: 128 MB Max Memory Used: 12 MB
  | 2022-05-30T13:22:57.443-07:00 | Unknown application error occurred Unhandled
  | 2022-05-30T13:22:57.904-07:00 | error: Module not found "file:///var/task/tmp/runtime.js".
  | 2022-05-30T13:22:57.945-07:00 | error: deno exited
@hayd
Copy link
Contributor

hayd commented May 30, 2022

Thanks, I haven't really used terraform so this is interesting!
Could you share the steps how you generated these files? or did you create them all?


That error is definitely bad. 🤔

Some thoughts from reading the scripts:

Can you remove the /dev/nulls from this file and see if there is any helpful output?
https://github.com/kyeotic/deno-lambda-repro/blob/main/scripts/bundle_lambda#L14-L32

Also, potentially worth trying the bundle method/line instead?

@kyeotic
Copy link
Author

kyeotic commented May 30, 2022

The dev/null pipes just hide all the individual file noise. You can comment them out and see no errors are being hidden. Again, this exact setup works without the import map; just replace the import with one directly to the url (or check out the working-deps branch and deploy that).

You have to have terraform installed to use these, but the deploy step is simply

// from the project root folder
./scripts/deploy dev // (or whatever)

You can run bundle_lambda on its own if you just want to see the zip it produces, but deploy will run that on its own. As far as how they were generated... I've been using terraform for a while, they've been copied and developed over a few years. The core "deno lambda" bundling logic came from this repo though, its nothing special except for the additional of the import map.

@hayd
Copy link
Contributor

hayd commented May 30, 2022

Related from #176:

The failure to transform DENO_IMPORTMAP = "./import_map.json" the way $LAMBDA_TASK_ROOT/$HANDLER_FILE is possibly a bug, but I don't think it is related.

@gm112
Copy link

gm112 commented Jul 29, 2022

The fix may possibly be to add a mapping of $LAMBDA_TASK_ROOT as a redirect to ./ in import_map.json, possibly? Can definitely confirm this is reproduceable with an empty zip file and a lambda function that is baked with the provided Deno runtime. Removing the import_map from the env var actually remedies the problem.

Bundling works around this problem for now.

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

3 participants