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

Support for clojure.stacktrace ns #721

Closed
ikappaki opened this issue Oct 15, 2023 · 0 comments · Fixed by #864
Closed

Support for clojure.stacktrace ns #721

ikappaki opened this issue Oct 15, 2023 · 0 comments · Fixed by #864
Labels
issue-type:enhancement New feature or request lang Issue pertaining to Basilisp language modules

Comments

@ikappaki
Copy link
Contributor

It would be useful to support clojure.stacktrace fns

https://clojuredocs.org/clojure.stacktrace

e.g. print-cause-trace is used by the CIDER nrepl client to print out a stacktrace.

chrisrink10 pushed a commit that referenced this issue Dec 15, 2023
…730)

Hi,

could you please review patch to introduce a new namespace
`basilisp.stacktrace` and a `print-cause-trace`. It partly addresses
#721.

This is a requirement of the upcoming nbb nrepl-server port implemented
in #723. CIDER specifically requests this function when an exception is
thrown to display to the user, making it essential.

thanks

Co-authored-by: ikappaki <ikappaki@users.noreply.github.com>
chrisrink10 added a commit that referenced this issue Dec 28, 2023
Hi,

could you please review patch to port
[nbb](https://github.com/babashka/nbb)'s build in nrepl-server to
basilisp contrib. It addresses #412.

`nbb` has the same EPL-1.0 license as `basilisp` so I believe using its
code as the base for this PR should not cause licensing issues.

The nbb `bencode` module which is a dependency was ported as well.
Extensive tests were written for both.

The server has been tested to work with both
[CIDER](https://github.com/clojure-emacs/cider) and
[Calva](https://github.com/BetterThanTomorrow/calva) in VS-Code.

The server can be invoked with `baslisp nrepl-server`:
```
$ poetry run basilisp nrepl-server -h
usage: basilisp.cmd nrepl-server [-h] [--host HOST] [--port PORT] [--port-filepath PORT_FILEPATH]

Start the nREPL server.

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           the interface address to bind to, defaults to 127.0.0.1.
  --port PORT           the port to connect to, defaults to 0 (random available port).
  --port-filepath PORT_FILEPATH
                        the file path where the server port number is output to, defaults to ".nrepl-port".
```

Several fixes were required to make it work, which are included as
separate commits in this PR prior to the main bencode and nrepl-server
commits. They address the following issues

- ~~Fixed issue with sort-* fns returning an error on empty seqs
(#716)~~
- Fix issue with `ns` being unavail after `in-ns` during `eval` (#718)
- Fixed issue with import modules aliasing using ns eval (#719)
- Fixed issue with `ns-resolve` throwing error on macros (#720)

support for the `basilisp.stacktrace/print-cause-trace` is also added
because it is requested by CIDER when an exception is thrown to show to
the user, which is essential, it partially addresses #721.

In addition, two issues were observed while running the tests in CI
- ~~The 1.6.0 was released few days ago and complains for an additional
type error in the generator, which is now ignored with this patch~~

``` 
Traceback (most recent call last):
#...
py311-mypy: commands[0]> mypy --config-file=C:\src\basilisp/pyproject.toml -p basilisp
src\basilisp\lang\compiler\generator.py:3530: error: Argument 1 to "fields" has incompatible type "type[IType]"; expected an attrs class  [misc]
src\basilisp\lang\compiler\generator.py:3530: note: Error code "misc" not covered by "type: ignore" comment
``` 

- The nrepl-server tests which are using threads were failing due to
trying to release an rlock which has been already released whose essence
is captured in #722, and is fixed with this patch as described in the
ticket by using `with self._lock.gen_rlock()` instead of a single
instance of `with self._rlock()`. The error was
```
    File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/basilisp/lang/runtime.py", line 706, in find
    return v
   File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/readerwriterlock/rwlock.py", line 49, in __exit__
    self.release()
   File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/readerwriterlock/rwlock.py", line 344, in release
    if not self.v_locked: raise RELEASE_ERR_CLS(RELEASE_ERR_MSG)
 RuntimeError: release unlocked lock
```

I understand this could be a lot to go through and there likely to be
multiple iterations while I update the code with your feedback, of which
I'm looking forward to.

I have not written a nrepl-server section for the manual yet. I plan to
do this after a successful review, and will also update the changelog.

Thanks

---------

Co-authored-by: ikappaki <ikappaki@users.noreply.github.com>
Co-authored-by: Chris Rink <chrisrink10@users.noreply.github.com>
@chrisrink10 chrisrink10 added this to the Release v0.1.0b1 milestone Dec 29, 2023
@chrisrink10 chrisrink10 added issue-type:enhancement New feature or request lang Issue pertaining to Basilisp language modules labels Dec 30, 2023
@chrisrink10 chrisrink10 modified the milestones: Release v0.1.0b1, Release v0.1.0b2, Release v0.2.0 Jan 23, 2024
chrisrink10 added a commit that referenced this issue Feb 8, 2024
Fixes #721

---------

Co-authored-by: Christopher Rink <christopher@ChristophersMBP.cjlocal>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-type:enhancement New feature or request lang Issue pertaining to Basilisp language modules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants