nova-ruby / rails

Ruby on Rails and Ruby support for Nova editor.
19 stars 7 forks source link

Extension starts with an `null is not an object` Exception #15

Open eirvandelden opened 2 years ago

eirvandelden commented 2 years ago

What I did

What I expected

Extension to start and display documentation/auto completion

What I got

The following error in Extensions Log:

Extension encountered an uncaught exception:
/Users/eirvandelden/Library/Application Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js (Line 362, Column 14)
TypeError: null is not an object (evaluating 'strings.forEach')
    @file:///Users/eirvandelden/Library/Application%20Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js:362:14
    @[native code]
    promiseReactionJob@[native code]
eirvandelden commented 2 years ago

Adding my rails about:

🐿  rails about
About your application's environment
Rails version             5.2.6
Ruby version              2.7.5-p203 (x86_64-darwin20)
RubyGems version          3.1.6
Rack version              2.2.3
JavaScript Runtime        Node.js (V8)
Middleware                Webpacker::DevServerProxy, Rack::MiniProfiler, Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, RequestStore::Middleware, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, BetterErrors::Middleware, Appsignal::Rack::RailsInstrumentation, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, Rack::Attack, Rakismet::Middleware, Rack::Attack
Application root          /Users/eirvandelden/Developer/reservations
Environment               development
Database adapter          postgresql
Database schema version   20211124092117

This might be a duplicate of #10 🤔

tommasongr commented 2 years ago

@eirvandelden Hi there!

I think is something similar to #10. However strings.forEach is not used for the About view but for the Notes view. Can you send me the result of the command bin/rails notes? Thanks

P.S: strings is definitely not a great variable name, I know 😅 I should definitely clean up here and there ahah

eirvandelden commented 2 years ago

Hi @tommasongr :)

Here is the output for bin/rails notes:

🐿  bin/rails notes
app/javascript/controllers/themed_widget_controller.js:
  * [393] [TODO] cleanup
  * [519] [TODO] Then, trigger changed
  * [544] [TODO] investigate if we need to add stimulus click actions?
  * [587] [TODO] investigate if we can remove this
  * [639] [TODO] remove me. Debug ALL the things!
  * [672] [TODO] VERIFY THIS WORKS

config/application.rb:
  * [105] [TODO] maybe remove widget-themed.css when it is done

lib/generators/factory_bot.rb:
  * [  2] [TODO] rename file

Note: the first line is my terminal. I replaced the default $ with an emoji because that is more fun 🤡

You make this in your free time, we can excuse a badly named variable 😉 I would have made a PR myself, but the first Feature I want to add is debugger support. I saw in #11 you don't have to do much debugging. I can better help with adding debugger support 😄

tommasongr commented 2 years ago

Got it! Of course it was a regex issue... 🙄 The last TODO line number wasn't catch because of the double white space resulting null...

I'll push a fix shortly.

CleanShot 2022-04-04 at 21 47 35@2x

The squirrel is definitely a nice one 😉 ahah


I would have made a PR myself, but the first Feature I want to add is debugger support. I saw in https://github.com/tommasongr/nova-rails/issues/11 you don't have to do much debugging. I can better help with adding debugger support

You are more than welcome to contribute to the extension as much as you want! 😄 It would be awesome to have some help and most importantly new ideas and points of view. Right now I'm developing the extension based on my needs and what I think might be useful, but that's my workflow. Someone else might need something different.

Specifically about the debugger however, I've made a follow-up to #11 about a conversation with Panic on the debugger for Ruby. They said they are willing to support it first party in an upcoming release. If you want to experiment with it and you get something working maybe we can add it temporarily but is possible it would turn out in a waste of time. It's your call.

Besides the debugger, if you have other ideas you want to discuss I'm always here 😆

tommasongr commented 2 years ago

v5.1 should fix your issue! Let me know if it works 😄

eirvandelden commented 2 years ago

Wow, you were quick to get a fix out!

Curious, it is still booting with the same exception:

Extension encountered an uncaught exception:
/Users/eirvandelden/Library/Application Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js (Line 362, Column 14)
TypeError: null is not an object (evaluating 'strings.forEach')
    @file:///Users/eirvandelden/Library/Application%20Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js:362:14
    @[native code]
    promiseReactionJob@[native code]

And I can confirm I don't see anything in the sidebar under Notes or the About.

For completeness sake, here are both full notes and about output: notes

🐿  bin/rails notes
app/javascript/controllers/themed_widget_controller.js:
  * [393] [TODO] cleanup
  * [519] [TODO] Then, trigger changed
  * [544] [TODO] investigate if we need to add stimulus click actions?
  * [587] [TODO] investigate if we can remove this
  * [639] [TODO] remove me. Debug ALL the things!
  * [672] [TODO] VERIFY THIS WORKS

config/application.rb:
  * [105] [TODO] maybe remove widget-themed.css when it is done

lib/generators/factory_bot.rb:
  * [  2] [TODO] rename file

about

🐿  bin/rails about
About your application's environment
Rails version             5.2.6
Ruby version              2.7.5-p203 (x86_64-darwin20)
RubyGems version          3.1.6
Rack version              2.2.3
JavaScript Runtime        Node.js (V8)
Middleware                Webpacker::DevServerProxy, Rack::MiniProfiler, Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, RequestStore::Middleware, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, BetterErrors::Middleware, Appsignal::Rack::RailsInstrumentation, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, Rack::Attack, Rakismet::Middleware, Rack::Attack
Application root          /Users/eirvandelden/Developer/reservations
Environment               development
Database adapter          postgresql
Database schema version   20211124092117

Observation: notes ends with 2 empty lines, about ends with 1 empty line

tommasongr commented 2 years ago

Mmm that's annoying... I tested your output hard-coding it in the extension and worked fine... 🤷‍♂️

I've seen that you forked the repo. I'm sure it will be easier for you to debug the extension with the real environment.

eirvandelden commented 2 years ago

My thoughts exactly.

What's the process did you use to debug this issue?

What I tried now is:

But then I don't see any of the features, like Reload Extension 🤔

tommasongr commented 2 years ago

Oh sorry, I should have added this process to the CONTRIBUTING guidelines.

In order to see the changes you have to first install the npm packages, then run the process npm run watch.

There is also a one time command npm run build that does not watch for changes.

optikfluffel commented 2 years ago

Same issue here, running version 5.1 of the extension.

🚀 bin/rails notes
🚀 bin/rails about
About your application's environment
Rails version             7.0.2.3
Ruby version              ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
RubyGems version          3.3.7
Rack version              2.2.3
Middleware                ActionDispatch::HostAuthorization, Rack::Sendfile, ActionDispatch::Static, ActionDispatch::Executor, ActionDispatch::ServerTiming, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Sprockets::Rails::QuietAssets, Rails::Rack::Logger, ActionDispatch::ShowExceptions, WebConsole::Middleware, ActionDispatch::DebugExceptions, ActionDispatch::ActionableExceptions, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, ActionDispatch::PermissionsPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper
Application root          /Users/me/Desktop/logger-service
Environment               development
Database adapter          sqlite3
Database schema version   20220409202125
eirvandelden commented 2 years ago

I just had some time to have a second look at this.

In src/Scripts/helpers.js:114 the strings var is null, because str is empty. Nothing was added to str because rails notes as defined process did not run (correctly). The given status code is 1.

My advice would be to move reject code up, so we first check if str is still empty and the status code is 1 and then reject the promise, or else, assume we can rails notes ran and the output can be parsed.

Now just to figure out why rails notes didn't run at all 😞

eirvandelden commented 2 years ago

I got it 👍🏼 , I'm making a PR

tommasongr commented 2 years ago

I just released the fix with v5.2 🎉

Thanks again for the help!

optikfluffel commented 2 years ago

Sorry to day that it's still broken for me. Same error, but different line number with 5.2:

Ruby on Rails[11:10:24.626000] Extension encountered an uncaught exception:
/Users/me/Library/Application Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js (Line 380, Column 14)
TypeError: null is not an object (evaluating 'strings.forEach')
    @file:///Users/me/Library/Application%20Support/Nova/Extensions/com.tommasonegri.Rails/Scripts/main.dist.js:380:14
    @[native code]
    promiseReactionJob@[native code]

My rails notes output is just empty btw:

🚀 rails notes
JimFrostig commented 2 years ago

I get the same error message as @optikfluffel

tommasongr commented 2 years ago

I'm sorry that it hasn't been fixed completely... These days I'm working on a major update for the other extension I maintain (nova-vue). After that I'll be focused on refactoring and improving the code quality of this one. I hope I'll be able to solve the issue.