deligenius / view-engine

🚀A Template View Engine for Deno frameworks
MIT License
54 stars 15 forks source link

Not working on "Deno Deploy" #32

Open guildenstern70 opened 2 years ago

guildenstern70 commented 2 years ago

When deployed on Deno Deploy it gives the following error:

  EvalError: Code generation from strings disallowed for this context     at new Function ()     at 
  https://deno.land/x/view_engine@v1.5.0/lib/engines/ejs/ejs.js:117:28
  --
  isolate start time: 6938 us
guildenstern70 commented 2 years ago

See as an example

https://github.com/guildenstern70/SmartDeno

gjuoun commented 2 years ago

please use the newest version, thanks

guildenstern70 commented 2 years ago

It appears that the problem is still there:

`

0 EvalError: Code generation from strings disallowed for this context at new Function () at https://deno.land/x/view_engine@v10.5.1/lib/engines/ejs/lib/ejs.js:117:28
1 isolate start time: 2 milliseconds
2 EvalError: Code generation from strings disallowed for this context at new Function () at https://deno.land/x/view_engine@v10.5.1/lib/engines/ejs/lib/ejs.js:117:28
3 isolate start time: 2 milliseconds
4 EvalError: Code generation from strings disallowed for this context at new Function () at https://deno.land/x/view_engine@v10.5.1/lib/engines/ejs/lib/ejs.js:117:28
5 isolate start time: 2 milliseconds
6 EvalError: Code generation from strings disallowed for this context at new Function () at https://deno.land/x/view_engine@v10.5.1/lib/engines/ejs/lib/ejs.js:117:28
7 isolate start time: 2 milliseconds

`

gjuoun commented 2 years ago

Hey can you give me some code to reproduce it?

guildenstern70 commented 2 years ago

Sure, here it is: https://github.com/guildenstern70/SmartDeno

The code compiles and runs perfectly in local. The problem arises only when deploying on Deno Deploy.

gjuoun commented 2 years ago

The newest patch version view_engine@v10.5.1b should fix the problem. @guildenstern70

guildenstern70 commented 2 years ago

Ok, problem fixed... but now there is another problem:

View-Engine: Deno.readTextFileSync is not a function

Program starts, but web page is not displayed - again, only on Deno Deploy. Locally it works.

Logs here:

0 | 2022-04-21 6:54:22.928\|INFO \|> GET https://smart-deno-project.deno.dev/ - 1ms
-- | --
1 | View-Engine:  Deno.readTextFileSync is not a function
2 | views/index.njk
3 | 2022-04-21 6:52:8.841\|INFO \|> GET https://smart-deno-project.deno.dev/ - 0ms
4 | View-Engine:  Deno.readTextFileSync is not a function
5 | views/index.njk
6 | 2022-04-21 6:51:29.749\|INFO \|> GET https://smart-deno-project-t8m805gnc1g0.deno.dev/ - 0ms
7 | View-Engine:  Deno.readTextFileSync is not a function
8 | views/index.njk
9 | 2022-04-21 6:51:28.206\|INFO \|> GET https://smart-deno-project-t8m805gnc1g0.deno.dev/ - 1ms
10 | View-Engine:  Deno.readTextFileSync is not a function
11 | views/index.njk
12 | 2022-04-21 6:51:2.549\|INFO \|> GET https://smart-deno-project.deno.dev/ - 1ms
13 | View-Engine:  Deno.readTextFileSync is not a function
14 | views/index.njk
15 | 2022-04-21 6:50:21.499\|INFO \|> GET https://smart-deno-project.deno.dev/ - 2ms
16 | View-Engine:  Deno.readTextFileSync is not a function
17 | views/index.njk
18 | 2022-04-21 6:50:21.491\|WARN \|> 🦕 Deno server running at http://localhost:8000/ 🦕
19 | 2022-04-21 6:50:21.491\|INFO \|> Running in: /src
20 | 2022-04-21 6:50:21.490\|INFO \|> Setting up web routes...
21 | 2022-04-21 6:50:21.487\|INFO \|> Setting up routes...
22 | isolate start time: 0.003115203 seconds
hirefrank commented 2 years ago

I'm receiving the same issue. Any update?

hirefrank commented 2 years ago

From the Deno Deploy Discord

That module uses a sync API which is not supported on Deploy The best course of action for now would be to ask the maintainer to add support for async version as well

@gjuoun Is that a heavy lift to add that support? Thx!

gjuoun commented 2 years ago

@hirefrank @guildenstern70

https://github.com/deligenius/view-engine/pull/42