pkulchenko / fullmoon

Fast and minimalistic Redbean-based Lua web framework in one file.
MIT License
677 stars 29 forks source link

Issue with techbench example #2

Closed imaitland closed 2 years ago

imaitland commented 2 years ago

Hi, I am seeing this error when playing around with the techbench example. The below is for the /json route but same happens with /db. zip redbean.com .init.lua .lua/fullmoon.lua .lua/techbench.lua && sh ./redbean.com -vvmbag

I2022-06-06T15:09:28+000027:tool/net/redbean.c:5999:redbean:71541] (req) received 127.0.0.1:65423 HTTP11 GET https://localhost:8080/json "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:99.0) Gecko/20100101 Firefox/99.0"
V2022-06-06T15:09:28+000028:tool/net/redbean.c:6201:redbean:71541] (rsp) 200 OK
V2022-06-06T15:09:28+000027:/zip/.lua/fullmoon.lua:56:redbean:71541] (fm) match 7 route(s) against '/json'
V2022-06-06T15:09:28+000017:/zip/.lua/fullmoon.lua:56:redbean:71541] (fm) route '/plaintext' not matched
I2022-06-06T15:09:28+000009:/zip/.lua/fullmoon.lua:57:redbean:71541] (fm) route '/json' matched
I2022-06-06T15:09:28+000029:/zip/.lua/fullmoon.lua:236:redbean:71541] (fm) render template 'json'
W2022-06-06T15:09:28+000021:/zip/.lua/fullmoon.lua:58:redbean:71541] (fm) unexpected result from action handler: 'table: 0x1000800a7710' (table)
D2022-06-06T15:09:28+000010:tool/net/redbean.c:6350:redbean:71541] (stat) "/json" latency 173µs
I2022-06-06T15:09:28+000003:tool/net/redbean.c:3496:redbean:71541] (stat) sending 138 byte message
 HTTP/1.1 200 OK
 Content-Type: application/json
 Date: Mon, 06 Jun 2022 22:09:27 GMT
 Server: redbean/1.5 fullmoon/0.25
 Content-Length: 0
pkulchenko commented 2 years ago

@imaitland, thank you for the report. I don't see this issue running locally. Can you re-test on the current master branch (or at least 0.26+) and let me know if you still have the issue?

imaitland commented 2 years ago
git clone git@github.com:pkulchenko/fullmoon.git \
  && cd fullmoon \
  && curl https://redbean.dev/redbean-latest.com >redbean.com \
  && chmod +x redbean.com \
  && mkdir .lua \
  && cp fullmoon.lua .lua \
  && cp examples/techbench.lua .lua \
  && echo 'require "techbench"' >.init.lua \
  && zip redbean.com .init.lua .lua/fullmoon.lua .lua/techbench.lua \
  && bash -c './redbean.com -v' 
curl http://127.0.0.1:8080/json 

Produces:

500 Internal Server Error

/zip/.lua/fullmoon.lua:817: global 'EncodeJson' is not callable (a nil value)
stack traceback:
/zip/.lua/fullmoon.lua:817: in field 'handler'
/zip/.lua/fullmoon.lua:253: in function 'fullmoon.render'
(...tail calls...)
/zip/.lua/fullmoon.lua:474: in function </zip/.lua/fullmoon.lua:435>

Note: I am using zsh hence the funny command to launch redbean.

pkulchenko commented 2 years ago

Since you're using redbean 1.5, there are several methods that are missing that fullmoon relies on (EncodeJson is one of them). You need to compile redbean yourself or use binaries from the upcoming 2.0 release. I'm also working on a service that will allow you to run your application in a pkayground and get a fullmoon+redbean binary.

pkulchenko commented 2 years ago

@imaitland, can you re-test with the current redbean version: https://justine.lol/redbean/redbean-latest.com? I expect the issue to be resolved.

imaitland commented 2 years ago

Yes I will have some time this evening to give this a shot, will report back here.

imaitland commented 2 years ago

NVM, just did it, and yes, confirmed this now works.