magnars / prone Goto Github PK
View Code? Open in Web Editor NEWBetter exception reporting middleware for Ring.
License: Other
Better exception reporting middleware for Ring.
License: Other
Could we pull them from npm maybe?
Hi,
Thanks for creating this awesome library.
I'm trying to use it with lein-ring. Snippet from project.clj
:
:profiles {:dev {:aliases {"run-dev" ["trampoline" "run" "-m" "my-api/-main"]}
:ring {:stacktrace-middleware prone.middleware/wrap-exceptions}
:dependencies [[lein-ring "0.9.6"]]}
:uberjar {:aot :all}})
But that isn't taking place, nothing is happening.
What I'm doing wrong?
Lein 2.5.1, Clojure 1.7
Thanks again.
Using Austin's browser-connected-repl-js
causes syntax errors on the error page served by Prone.
We should look into taking advantage of ex-triage
and ex-str
, like the REPL now does: http://insideclojure.org/2018/12/17/errors/
It would be nice if the request map was sorted, to make it easier to find what you looking for without scanning each entry.
For example
:content-type "application/x-www-form-urlencoded"
:form-params {"username" "[email protected]" "password" "foobar"}
:async-channel "/0:0:0:0:0:0:0:1:8080<->/0:0:0:0:0:0:0:1:42667"<org.httpkit.server.AsyncChannel>
:server-name "localhost"
:query-string nil
:character-encoding "utf8"
would be nice if it were
:async-channel "/0:0:0:0:0:0:0:1:8080<->/0:0:0:0:0:0:0:1:42667"<org.httpkit.server.AsyncChannel>
:character-encoding "utf8"
:content-type "application/x-www-form-urlencoded"
:form-params {"username" "[email protected]" "password" "foobar"}
:query-string nil
:server-name "localhost"
better_errors
gem has the security note in Readme (https://github.com/charliesome/better_errors#security):
NOTE:
It is critical you put better_errors in the development section.
Do NOT run better_errors in production, or on Internet facing hosts.
Is prone safe for production? Is there anything a user should do to make it secure?
Thanks.
Compile-time errors "revert" to the default Ring stack trace page. We should investigate if there's some way we can render these pages as well.
The entire request map must be traversed, replacing all unreadables into their toString-form (and adding their original type).
I finally tracked down why I have stopped getting nice Prone stack traces. I suspect this began when I changed my project.clj
to include some evaluated forms to build my Manifest entry when creating Jar files:
;...
:uberjar-name "afterglow.jar"
:manifest {"Name" ~#(str (clojure.string/replace (:group %) "." "/")
"/" (:name %) "/")
"Package" ~#(str (:group %) "." (:name %))
"Specification-Title" ~#(:name %)
"Specification-Version" ~#(:version %)}
;...
The reason I suspect this is the problem is that now whenever I get a runtime error, instead of the nice Prone stack trace, I simply see “Error: 500 Something very bad has happened! We've dispatched a team of highly trained gnomes to take care of the problem.” And in my log file, I get a stack trace which ends:
prone.middleware/wrap-exceptions/fn middleware.clj: 94
prone.middleware/get-application-name middleware.clj: 20
prone.middleware/get-application-name/invokeStatic middleware.clj: 25
clojure.edn/read-string edn.clj: 37
clojure.edn/read-string/invokeStatic edn.clj: 37
clojure.edn/read-string/invokeStatic edn.clj: 46
java.lang.RuntimeException: Invalid leading character: ~
And, indeed, I just tried removing my :manifest
declaration, and I get back the lovely Prone stack trace. All right, now that I know this, when I encounter a problem I can shut down my REPL, hack the project.clj
, restart the REPL, and try to recreate the problem so I can see the actual error. But I would much prefer to have Prone be able to coexist with this kind of code in the project—as things stand, the Prone crash completely obscures the original problem that I would like to debug.
I need to keep the evaluated expressions in my project definition, in order to build name and version information which is displayed to the user at runtime when executing from a jar file, either standalone, or embedded in the Max/MSP visual programming environment. And the sample project.clj
in Leiningen itself includes such examples, so I very much hope this is something that Prone can be made to accommodate?
I know it's still in alpha, just wanted to raise heads up. It does look to be incompatible. Tried on latest available at the time [org.clojure/clojure "1.9.0-alpha11"]
. Thanks
I understand that content-type header is technically not required, however it seems like a best practice to include it whenever possible. For example, Rails includes content-type when serving assets. Do you think it can be included here as well? The resources missing content-type are prone.js and prone.css.
HTTP/1.1 200 OK
Cache-Control: max-age=315360000
X-Runtime: 6.317E-6
Content-Length: 3402889
Server: http-kit
Date: Tue, 16 Jun 2020 17:27:21 GMT
The reason why I noticed this is that we have Clojure server sitting behind a reverse proxy, and when the proxy handles a response, it automatically sets missing content-type to default - text/plain. This makes browsers ignore assets, breaking the debug page.
Maybe we should add some friendly hints when you get one of Clojure's notorious error messages? ("Don't know how to create ISeq from: clojure.lang.Symbol"
, I'm looking at you). Something along the lines of "This usually occurs when ..."?
Have you thought of porting prone to nodejs?
I would like to see this and I don't mind contributing. Do you have any pointers?
Hi,
Getting this error from prone javascript code.
Uncaught Error: Could not find tag parser for :prone.prep in ("inst" "uuid" "queue" "js")
It seems cljs.reader not able to read tagged value sent by prone server. How to resolve this?
Thanks!
I cannot see code snippets from .cljc
files.
Did:
.cljc
fileHappened:
(could not locate source file on class path)
.cljc
not .java
.invoke
or doInvoke
for .cljc
files.I don't have any problems with .clj
files.
I have not tried to reproduce this with a minimal setup yet. Will update this issue when I have.
When an error happens with pgsql, you see some description with helpful text saying "call .getNextException to see the cause". Having some ability to pre-process exception before showing it to user would be nice, I could write application-specific one for instance. :)
There should be extension points to further improve error reporting.
One such plugin could improve the schema data structure error (that's presented as text in the exception message):
Value does not match schema: {:articles {"/bah.md" (not (every? (check % a-clojure.lang.PersistentArrayMap) schemas))}}
I use https://github.com/thheller/shadow-build to build my cljs and its finding prone's cljs on the classpath and builds them into my cljs (and then it all breaks).
Is it possible to get prone working in an uberwar'd environment? Right now it breaks because project.clj doesn't exist.
We need some sort of sanity check for displaying code, because clicking frames pointing at clojure.core
takes about 30 seconds to render.
Hi,
I have a web app, in which I use buddy-auth and prone (in dev mode).
I've implemented session authentication same as in this example.
In this example if user is not authenticated then the exception is raised:
(defn home
[request]
(if-not (authenticated? request)
(throw-unauthorized)
(let [content (slurp (io/resource "index.html"))]
(render content request))))
This exception should be handled then by the buddy code:
(def auth-backend
(session-backend {:unauthorized-handler unauthorized-handler}))
but in the development mode this doesn't work, because prone is catching and handling this exception. Is there any way to pass it down, to the unauthorized-handler?
Thanks in advance!
I really like prone, but it generates urls which start with various numbers (like /1320042293/prone.css
). And it's a bit hard to use those because of how my environment is configured (I can proxy only specific prefixes to a clojure app).
I wonder if it's possible to put it under some url like /prone
, so the url will be /prone/123/prone.css
or /prone/prone.css
.
Clojure is licensed under the Eclipse Public License, and most libraries seem to use the same license. Unfortunately, this license is incompatible with the GPL (see FSF's own explanation), so that makes prone legally incompatible with almost every Clojure library. In fact, I would imagine that the Clojure standard library has the same license, so I don't think it's even possible to have a legal Clojure program that uses prone :-(
The lazier/easier alternative would be to use EPL, although I would imagine that any "liberal" license (BSD and such) would work, too.
Hi there,
I'm using ring with aleph and I'm trying to make prone work on top of aleph. Main problem is that aleph kind of breaks ring spec by allowing to return futures as a response. Normal way to port middleware is to use let-flow that aleph provides and reuse partial functionality from the middleware. But with prone most of logic is encapsulated in a wrap-exception function so my question is what would be idiomatic way to solve this problem? Should I just try to port entire wrapper? I'm mostly puzzled by things like debug/debug-data and why it's always empty for my errors.
Thanks!
My application throws an exception like this:
#error {
:cause "Can't infer the SQL type to use for an instance of clojure.lang.Keyword. Use setObject() with an explicit Types value to specify the type to use."
:via
[{:type org.postgresql.util.PSQLException
:message "Can't infer the SQL type to use for an instance of clojure.lang.Keyword. Use setObject() with an explicit Types value to specify the type to use."
:at [org.postgresql.jdbc.PgPreparedStatement setObject "PgPreparedStatement.java" 1039]}]
:trace
[[org.postgresql.jdbc.PgPreparedStatement setObject "PgPreparedStatement.java" 1039]
[com.zaxxer.hikari.pool.HikariProxyPreparedStatement setObject "HikariProxyPreparedStatement.java" -1]
[clojure.java.jdbc$eval4067$fn__4068 invokePrim "jdbc.clj" 341]
;;; etc
But instead of Prone’s lovely debug UI, I get this:
java.lang.IndexOutOfBoundsException
at clojure.lang.PersistentVector.arrayFor(PersistentVector.java:158)
at clojure.lang.PersistentVector.nth(PersistentVector.java:162)
at clojure.lang.RT.nth(RT.java:853)
at prone.code_trunc$find_top_level_form.invokeStatic(code_trunc.clj:18)
at prone.code_trunc$find_top_level_form.invoke(code_trunc.clj:8)
at prone.code_trunc$truncate.invokeStatic(code_trunc.clj:54)
at prone.code_trunc$truncate.invoke(code_trunc.clj:38)
at prone.prep$load_source.invokeStatic(prep.clj:26)
at prone.prep$load_source.invoke(prep.clj:20)
at prone.prep$add_source.invokeStatic(prep.clj:30)
at prone.prep$add_source.invoke(prep.clj:29)
at clojure.core$mapv$fn__6953.invoke(core.clj:6627)
at clojure.core.protocols$fn__6755.invokeStatic(protocols.clj:167)
at clojure.core.protocols$fn__6755.invoke(protocols.clj:124)
at clojure.core.protocols$fn__6710$G__6705__6719.invoke(protocols.clj:19)
at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:31)
at clojure.core.protocols$fn__6738.invokeStatic(protocols.clj:75)
at clojure.core.protocols$fn__6738.invoke(protocols.clj:75)
at clojure.core.protocols$fn__6684$G__6679__6697.invoke(protocols.clj:13)
at clojure.core$reduce.invokeStatic(core.clj:6545)
at clojure.core$mapv.invokeStatic(core.clj:6618)
at clojure.core$mapv.invoke(core.clj:6618)
at prone.prep$prep_error$fn__12840.invoke(prep.clj:114)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:648)
at clojure.core$update_in.invokeStatic(core.clj:5950)
at clojure.core$update_in.doInvoke(core.clj:5939)
at clojure.lang.RestFn.invoke(RestFn.java:445)
at prone.prep$prep_error.invokeStatic(prep.clj:110)
at prone.prep$prep_error.invoke(prep.clj:106)
at prone.prep$prep_error_page.invokeStatic(prep.clj:149)
at prone.prep$prep_error_page.invoke(prep.clj:148)
at prone.middleware$exceptions_response.invokeStatic(middleware.clj:92)
at prone.middleware$exceptions_response.invoke(middleware.clj:87)
at prone.middleware$wrap_exceptions$fn__12928.invoke(middleware.clj:129)
(etc)
This is using HugSQL, FWIW, so some of the functions the exception passes through are created by macros.
I've got 1.5.1
prone version and getting this exception:
Unable to resolve symbol: inst? in this context, compiling:(prone/prep.clj:85:5)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: inst? in this context
After upgrading to prone 1.1.2 this error occurs in prone.js
line 22055:
Uncaught SyntaxError: Invalid regular expression: /[A-Za-zÀ-ÖØ-öø-??-??-???-??-??-?]/: Range out of order in character class
prone 1.1.1 works fine but 1.1.2 fails on Firefox/Chrome/IE/...
Is it a problem with server response encoding maybe?
Is there any documentation about how to setup prone, immutant 2 and compojure?
At the moment prone
catches only java.lang.Exception
s - which does not include AssertionError
s, among other error classes.
Is it intentional? Since prone
is used in development, it would be good to be use it for debugging the code with assertions and pre- and post-conditions.
Would you consider making prone
's middleware catch all Error
s (or even any Throwable
)? Or, alternatively, is there any other way to have the debug output for assertion failures?
The [prone 0.8.0]
.jar contains a whole lot of .cljs and .js files that are not required for its operation and confuse the cljs compiler when prone is used as a dependency.
Small excerpt:
0 Fri Oct 17 20:49:20 CEST 2014 prone/generated/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/
3502 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/buffers.cljs
9775 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/buffers.js
7151 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/channels.cljs
17470 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/channels.js
1214 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/dispatch.cljs
2537 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/dispatch.js
4958 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/ioc_helpers.cljs
26286 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/ioc_helpers.js
1434 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/protocols.cljs
8879 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/protocols.js
5471 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/timers.cljs
11596 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async/impl/timers.js
29134 Fri Oct 17 20:49:30 CEST 2014 prone/generated/out/cljs/core/async.cljs
246316 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/core/async.js
220793 Fri Oct 17 20:49:26 CEST 2014 prone/generated/out/cljs/core.cljs
699075 Fri Oct 17 20:49:30 CEST 2014 prone/generated/out/cljs/core.js
18071 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/reader.cljs
37022 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/cljs/reader.js
179 Fri Oct 17 20:49:26 CEST 2014 prone/generated/out/cljs/user.js
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/
0 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/
2950 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/event.cljs
5915 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/event.js
5382 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/net.cljs
19084 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/net.js
4204 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/repl.cljs
6817 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/browser/repl.js
5140 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/string.cljs
7850 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/string.js
3311 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/walk.cljs
3906 Fri Oct 17 20:49:32 CEST 2014 prone/generated/out/clojure/walk.js
The resources
folder is included in the jar and all tools (lein cljsbuild
, build-js-sources.sh
) are configured to put their output there. Those file should not be in a release jar though.
Should be enough to have
2176452 Fri Oct 17 21:00:08 CEST 2014 prone/generated/prone.js
2046841 Thu Aug 28 16:21:34 CEST 2014 prone/generated/prone.js.map
The stack trace for compilation errors does not contain any application frames.
However, there is one clue in the message:
java.lang.RuntimeException: Unable to resolve symbol: prep in this context, compiling:(zombieclj/sweeper/game_loop.clj:7:5)
Maybe we could include this as a special frame?
Hey friends,
I tried running the test suite with clojure 1.10.3 and ran into some failures because of hardcoded assumptions about Reflector.java
that have changed since 1.8. I'm not sure what a viable solution here is, as the tests are predicated on correctly listing entirely implementation-dependent information:
prone/test/prone/stacks_test.clj
Lines 33 to 44 in b2314aa
prone/test/prone/stacks_test.clj
Lines 46 to 64 in b2314aa
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.