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

Browser tab changes not applied in real-time #171

Open
velios opened this issue May 4, 2024 · 4 comments
Open

Browser tab changes not applied in real-time #171

velios opened this issue May 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@velios
Copy link
Contributor

velios commented May 4, 2024

Hello. First of all thx for amazing tool and that you find time to develop the project so dynamically.

Recently browser tab in ClojureStorm mode was improved. But the changes in this tab are not applied and I would like to know if this is intended. Let me give an example.

Let's say I created a simple pedestal application using the official guide.
lein new pedestal-service the-next-big-server-side-thing

Now I launch the application with the storm enabled.

:dependencies
[[com.github.flow-storm/clojure "1.12.0-alpha11"]
 [com.github.flow-storm/flow-storm-dbg "3.15.3"]]

:jvm-opts ["-Dclojure.storm.instrumentAutoPrefixes=true"]

Now i follow instructions and run app with (def dev-serv (run-dev)) and visit example route localhost:8080 and see Hello world message. All fine.

My browser tab looks like this
image

Now I realized that I want to see the interceptors that work when the handler is called. I know I'm interested in the function io.pedestal.interceptor.chain/try-f, so i add ns io.pedestal.interceptor.chain in browser tab
image
And now my browser tab looks like this
image
But if i visit example route localhost:8080 again I still don't see the function try-f. Actually no one function from added io.pedestal.interceptor.chain ns. I tried pressing all the refresh buttons I saw, but nothing changed.

But if before the start i add configuration
"-Dclojure.storm.instrumentOnlyPrefixes=io.pedestal.interceptor.chain" and compeletly refresh project. All works as expected and try-f captured by flowstorm.

The same is true for skip ns and skip regex functionality.
image

@jpmonettas
Copy link
Member

Hi @velios. Glad you find FlowStorm useful!

Yes this is not a bug, but how things work. When you start the JVM with "-Dclojure.storm.instrumentOnlyPrefixes=io.pedestal.interceptor.chain" then all functions in namespaces with that prefix will be compiled instrumented, so you can record them.

When you start withtout the prefix, then all those functions will be compiled normally (like with the official compiler) and just adding a prefix with the browser doesn't change anything, just tells the compiler that whatever gets compiled from now on under those namespaces should be instrumented.

What you need after adding the prefix is to reload those namespaces. Take a look at the note here on the User's Guide https://flow-storm.github.io/flow-storm-debugger/user_guide.html#_modifying_instrumentation_with_the_browser for various ways to do it.

@velios
Copy link
Contributor Author

velios commented May 4, 2024

Thx for answer, @jpmonettas

I've read the documentation, but there are still questions that I have. Using the same example that I started with above.

The general list of namespaces lists all the namespaces that I loaded into the project, and not just those that I asked to instrument. And it really gives me the ability to follow the documentation and reload the namespaces that I want to track.

image

But at the same time it gives a feeling of some inconsistency. Because Add instrumentation prefix works with patterns, but Reload namespace with specific namespace. So i need to click every namespace and reload it, but i can't reload it by pattern. Perhaps my proposal is incorrect and I simply could not understand why the behavior is the way it is now, but I would like to suggest the following.

image

If this is due to performance issues, then for those who are not concerned about this, it is possible to make a configuration key so that there is no dialog window every time. Like this.
-Dclojure.storm.autoReloadInstrumentedNamespaces=true

This seems to be a different proposal, but functionality like on next screenshot also feels valuable.

image

I drew examples only for the add pattern, but the same capabilities seem to be in demand for delete patterns. And it seems like it would provide useful visual feedback to better control what will be recorded next time.

@jpmonettas
Copy link
Member

I think your proposal is great, I have also considered it. I just haven't implemented it yet because namespaces needs to be loaded in topological order, so I'll have to include or replicate some of the code in tools.namespace or clj-reload.
In the meantime you can also do a (require 'some.lib.core.ns :reload-all)
That should recursively reload all de dependents namespace in order.

@jpmonettas
Copy link
Member

I just implemented this to use clj-reload when it is on the classpath but just figured that clj-reload can currently only reload namespaces from files coming from your sources and not from libraries.
I'll check first how hard it is to implement that on clj-reload and maybe suggest it as a feature.

My idea was to show an alert after changing a prefix saying that FlowStorm can automatically reload the namespaces for you if clj-reload was on the classpath. This way we don't need to maintain code for topologically re-loading namespaces (which also need ns dependencies parsing) and reloading inside FS codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants