#I need help with 'EROR Errored(Undef)' supposedly caused by wisp/mist with the wrong Erlang version
1 messages · Page 1 of 1 (latest)
It's worth noting this is being run within a docker container:
FROM ghcr.io/gleam-lang/gleam:v1.4.1-erlang-alpine
# Install build dependencies
RUN apk add --no-cache gcc musl-dev make wget sqlite sqlite-dev
WORKDIR /build
COPY . /build
# Create DB
RUN chmod +x /build/create_db.sh
RUN /build/create_db.sh
# Compile the project
RUN cd /build \
&& gleam export erlang-shipment \
&& mv build/erlang-shipment /app \
&& rm -r /build
# Run the server
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["run"]
is there anything else printed?
Nope
Well, the rest of wisp's logs are being printed
this other post encountered the same issue https://discord.com/channels/768594524158427167/1267148683296899083
from the wisp logs (on fly.io):
2024-09-19T10:17:09Z app[3287154db30038] jnb [info]"decoding save draft"
2024-09-19T10:17:09Z app[3287154db30038] jnb [info]EROR Errored(Undef)
2024-09-19T10:17:09Z app[3287154db30038] jnb [info]INFO 500 POST /publish
Is nothing else printed at all?
the docker image should have a suitable Erlang version but can you check what it is? with erl
That container is OTP27
So it's not this
Yeah, it seems to be the correct erlang version:
9185e270a2e198:/app# erl
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [jit:ns]
Eshell V15.0 (press Ctrl+G to abort, type help(). for help)
1> ^C
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
(l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
^C9185e270a2e198:/app#
Do you use any @external or NIFs in your application?
I'd actually forgotten that I had
Strangely this error is not occuring locally
But in the container it's giving an issue. It could be from the following external function I'm using:
pub type DateTime = String
@external(erlang, "ffi", "format_iso8601")
pub fn now() -> DateTime{}
where ffi.erl:
% Taken from https://stackoverflow.com/questions/41777852/erlang-return-time-in-utc-format
-module(ffi).
-export([format_iso8601/0]).
format_iso8601() ->
{{Year, Month, Day}, {Hour, Min, Sec}} =
calendar:universal_time(),
iolist_to_binary(
io_lib:format(
"~.4.0w-~.2.0w-~.2.0wT~.2.0w:~.2.0w:~.2.0wZ",
[Year, Month, Day, Hour, Min, Sec] )).
btw I suggest using another name for your ffi module than ffi since that is likely to conflict
You want to remove the {} from that external definition as you're saying there that it's valid to call that on JavaScript, but there it will fail
I couldn't say what the issue is with the exception though.
All good, thanks for the help
was it fixed?
Not yet 😦
It strangely works with the packages I have locally but rebuilding with no cache leads to this issue
I fear it might be an external package
did you change the ffi module name?
Yes and it's working now!
That was the problem
Thank you so much
I wouldn't have figured it out without your help
I suppose the build order is different somehow and a different module wins in your Docker environment than locally
that means some package has a module called ffi and that's not nice, is your packages list long? we could file an issue on the package…
here's my gleam.toml
[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
wisp = ">= 0.16.0 and < 1.0.0"
sqlight = ">= 0.9.0 and < 1.0.0"
cake = ">= 1.1.1 and < 2.0.0"
argv = ">= 1.0.2 and < 2.0.0"
gleam_crypto = ">= 1.3.0 and < 2.0.0"
mist = ">= 1.2.0 and < 2.0.0"
gleam_http = ">= 3.6.0 and < 4.0.0"
gleam_erlang = ">= 0.25.0 and < 1.0.0"
gleam_otp = ">= 0.12.0 and < 1.0.0"
I'm not sure how to figure out which one is the cause though
The order is deterministic