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

error: Uncaught RangeError: Maximum call stack size exceeded #5

Open
Faeq-F opened this issue Aug 6, 2024 · 10 comments
Open

error: Uncaught RangeError: Maximum call stack size exceeded #5

Faeq-F opened this issue Aug 6, 2024 · 10 comments

Comments

@Faeq-F
Copy link

Faeq-F commented Aug 6, 2024

I'm trying to create a new project using glen. I am using the following code:

pub fn main() {
  glen.serve(8000, fn(_req) {
    "<h1>Welcome to my webpage!</h1>
    <p>Make yourself at home 😄</p>"
    |> glen.html(status.ok)
    |> promise.resolve
  })
}

with the following gleam.toml:

name = "app"
version = "1.0.0"
target = "javascript"
[javascript]
runtime = "deno"

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
glen = ">= 2.2.0 and < 3.0.0"
gleam_http = ">= 3.6.0 and < 4.0.0"
gleam_javascript = ">= 0.11.0 and < 1.0.0"
repeatedly = ">= 2.1.1 and < 3.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"

when I do gleam run I get

Compiled in 0.05s
    Running app.main
error: Uncaught RangeError: Maximum call stack size exceeded

If I downgrade glen, I still get this error. I don't know if I am missing something basic

@MystPi
Copy link
Owner

MystPi commented Aug 6, 2024

Hey, thanks for the report. Could you share your entire program code (including imports)?

@Faeq-F
Copy link
Author

Faeq-F commented Aug 6, 2024

My code was:

import gleam/javascript/promise.{type Promise}
import glen
import glen/status

pub fn main() {
  glen.serve(8000, fn(_req) {
    "<h1>Welcome to my webpage!</h1>
    <p>Make yourself at home 😄</p>"
    |> glen.html(status.ok)
    |> promise.resolve
  })
}

the code from the ReadMe does not work either;

import gleam/javascript/promise.{type Promise}
import glen
import glen/status

pub fn main() {
  glen.serve(8000, handle_req)
}

fn handle_req(req: glen.Request) -> Promise(glen.Response) {
  "<h1>Welcome to my webpage!</h1>
  <p>Make yourself at home 😄</p>"
  |> glen.html(status.ok)
  |> promise.resolve
}

They both produce the same error

@MystPi
Copy link
Owner

MystPi commented Aug 6, 2024

That's really strange, since the code is working on my platform (Ubuntu WSL on Windows). What versions of Gleam and Deno are you using? Personally I'm on Deno 1.43.3 and gleam 1.4.1.

@Faeq-F
Copy link
Author

Faeq-F commented Aug 6, 2024

I'm on Windows using gleam 1.3.2 and Deno 1.45.5

deno 1.45.5 (release, x86_64-pc-windows-msvc)
v8 12.7.224.13
typescript 5.5.2

@MystPi
Copy link
Owner

MystPi commented Aug 6, 2024

I would maybe try upgrading Gleam, though I kinda doubt that's the issue. Deno version doesn't change anything on my machine either.

Also—I can't remember how the compiler does this—is that the full error you shared, or is it truncated? It would be very helpful to know where it's coming from.

@Faeq-F
Copy link
Author

Faeq-F commented Aug 6, 2024

Updating gleam:

scoop update gleam
gleam: 1.4.1 (latest version)
Latest versions for all apps are installed! For more information try 'scoop status'

Running the project:

gleam run
  Compiling gleam_stdlib
  Compiling gleam_http
  Compiling gleam_javascript

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:53:23
   │
53 │ pub fn dereference(a: Reference(a)) -> a
   │                       ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:57:25
   │
57 │ pub fn set_reference(a: Reference(a), b: a) -> a
   │                         ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:61:32
   │
61 │ pub fn make_reference(a: a) -> Reference(a)
   │                                ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:64:30
   │
64 │ pub fn update_reference(ref: Reference(a), f: fn(a) -> a) -> a {
   │                              ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated value used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:65:15
   │
65 │   let value = dereference(ref)
   │               ^^^^^^^^^^^ This value has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated value used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:66:3
   │
66 │   set_reference(ref, f(value))
   │   ^^^^^^^^^^^^^ This value has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:72:27
   │
72 │ pub fn reference_equal(a: Reference(a), b: Reference(a)) -> Bool
   │                           ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge

warning: Deprecated type used
   ┌─ C:\dev\FYP\app\build\packages\gleam_javascript\src\gleam\javascript.gleam:72:44
   │
72 │ pub fn reference_equal(a: Reference(a), b: Reference(a)) -> Bool
   │                                            ^^^^^^^^^^^^ This type has been deprecated

It was deprecated with this message: The Reference type is being removed
from this packge
  Compiling conversation
  Compiling filepath
  Compiling gleam_json
  Compiling gleam_community_colour
  Compiling gleam_community_ansi
  Compiling gleeunit
  Compiling marceau
  Compiling glen
  Compiling repeatedly
  Compiling app

warning: Unused imported type
  ┌─ C:\dev\FYP\app\src\app.gleam:1:34
  │
1 │ import gleam/javascript/promise.{type Promise}
  │                                  ^^^^^^^^^^^^ This imported type is never used

Hint: You can safely remove it.
   Compiled in 0.35s
    Running app.main
error: Uncaught RangeError: Maximum call stack size exceeded

@MystPi
Copy link
Owner

MystPi commented Aug 6, 2024

That's a tough one! I can't immediately tell what's going on unfortunately. I can only think that it must be an issue with Windows, but I'm not at all sure why that could be.

@Faeq-F
Copy link
Author

Faeq-F commented Aug 6, 2024

ok, that's understandable, thank you for having a look. I will try to use a different environment like WSL

@Faeq-F
Copy link
Author

Faeq-F commented Aug 6, 2024

I just installed Ubuntu WSL and gleam & deno on it, and it works, thank you

@MystPi
Copy link
Owner

MystPi commented Aug 6, 2024

I'm glad it works for you! I'm not sure what the problem with Windows is; it would be nice for it to work on all platforms. I'll have to do some investigation.

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