40ants / 40ants/reblocks-websocket
Demo fails: `REBLOCKS/PAGE::*CURRENT-PAGE*` is unbound
- Dominant language
- Common Lisp
- Stars
- 7
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
I have create a small demo based off of the tutorial:
```lisp
(defpackage test
(:use #:cl
#:arrow-macros
#:reblocks-ui/form
#:reblocks/html)
(:import-from #:reblocks/widget
#:render
#:update
#:defwidget)
(:import-from #:reblocks/actions
#:make-js-action)
(:import-from #:reblocks/app-actions
#:define-action)
(:import-from #:reblocks/app
#:defapp)
(:import-from #:reblocks-websocket
#:websocket-widget)
(:export #:main))
(in-package #:test)
(defapp page :prefix "/")
(defwidget counter-box (reblocks-websocket:websocket-widget)
((counter :initform 0
:accessor counter)))
(defmethod initialize-instance ((instance counter-box) &rest restargs)
(declare (ignorable restargs))
(call-next-method)
(reblocks-websocket:in-thread ("Update counter")
(sleep 3)
;; Updating counter
(incf (counter instance))
(update instance)))
(defmethod reblocks/page:init-page ((app page) (url-path string) expire-at)
(declare (ignorable app url-path expire-at))
(make-instance 'counter-box))
(defmethod render ((instance counter-box))
(with-html
(:h1 "Counter: " (counter instance))
(with-html-form (:POST (lambda (&key action &allow-other-keys)
(cond
((equal action "+")
(incf (counter instance)))
((equal action "-")
(decf (counter instance))))
(update instance)))
(:input :type :submit :name "action" :value "+")
(:input :type :submit :name "action" :value "-"))))
(defun main ()
(reblocks/server:start :port 4000))
```
But on first page load I get this error:
```
The variable REBLOCKS/PAGE::*CURRENT-PAGE* is unbound.
[Condition of type UNBOUND-VARIABLE]
Restarts:
0: [CONTINUE] Retry using REBLOCKS/PAGE::*CURRENT-PAGE*.
1: [USE-VALUE] Use specified value.
2: [STORE-VALUE] Set specified value and use it.
3: [ABORT] Abort request processing and return 500.
4: [RESET-SESSION] Reset current Weblocks session and return 500.
5: [ABORT] abort thread (#)
Backtrace:
0: ((:METHOD INITIALIZE-INSTANCE (TEST::COUNTER-BOX)) #) [fast-method]
1: (SB-PCL::FAST-MAKE-INSTANCE # #)
2: ((:METHOD REBLOCKS/PAGE:INIT-PAGE :AROUND (T STRING T)) # "/websocket" NIL) [fast-method]
3: (REBLOCKS/PAGE::CALL-WITH-PAGE-DEFAULTS #)
4: ((LAMBDA (#:G43 &REST #:G44) :IN REBLOCKS/REQUEST-HANDLER:HANDLE-REQUEST) NIL)
5: ((:METHOD REBLOCKS/REQUEST-HANDLER:HANDLE-REQUEST (REBLOCKS/APP:APP)) #) [fast-method]
6: ((FLET "doit-46" :IN REBLOCKS/REQUEST-HANDLER:HANDLE-REQUEST))
7: ((:METHOD REBLOCKS/REQUEST-HANDLER:HANDLE-REQUEST :AROUND (T)) #) [fast-method]
8: (LOG4CL-EXTRAS/ERROR::CALL-WITH-LOG-UNHANDLED # :DEPTH NIL :ERRORS-TO-IGNORE NIL)
9: ((LAMBDA NIL :IN REBLOCKS/REQUEST-HANDLER:HANDLE-REQUEST))
10: (REBLOCKS/ERROR-HANDLER::CALL-WITH-HANDLED-ERRORS #)
11: ((FLET REBLOCKS/RESPONSE::WITH-RESPONSE-THUNK :IN REBLOCKS/SERVER::HANDLE-HTTP-REQUEST))
12: (REBLOCKS/RESPONSE::CALL-WITH-RESPONSE #)
13: ((LAMBDA NIL :IN REBLOCKS/SERVER::HANDLE-HTTP-REQUEST))
14: (REBLOCKS/APP::CALL-IN-WEBAPP # #)
15: ((FLET REBLOCKS/HOOKS:CALL-NEXT-HOOK :IN REBLOCKS/COMMANDS-HOOK::RESET-COMMANDS-LIST))
16: ((FLET REBLOCKS/COMMANDS-HOOK::RESET-COMMANDS-LIST :IN "/nix/store/iaddlq8j9c8p9aqvz5i0rfyf4ij3mk4s-system-reblocks/src/commands-hook.lisp") (#
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.