Issue in rendering swagger-editor in react second time - javascript

I am embedding swagger-editor package into my react application, when i fetch the swagger specifications from github, first time it works fine and validate it perfectly, but when i render it second time, it throws error like below, after this error it skips some validation and its really defeat the purpose as this primary purpose is to validate the spec errors. i understand swagger-editor spawns the webworker, and second time also its starts new instance and the previous instance remains there. Is there anyway to overcome this situation?
error is this 'Worker caught an error: Error: schema with key or id "openapi-2.0" already exists'

I have this same issue, and looking on swagger-editor github repo, I found this issue 2339.
It seen you have to terminate the webworker process.
Worker Docs

Related

Cypress tests fail when running headless but pass when running on Cypress interface

I can run my test script on the Cypress interface with npx cypress open. In this case test runs pass. But when I run the same test script headless, it fails. What can be the cause of this issue?
I run the tests always behind OpenVPN both when running headless or on Cypress interface. This is required due to authentication API.
I wanted to mention that, not always the same tests are failed. While testing headless than my tests fails randomly. But when I run these tests on the Cypress interface everything passes without any error.
OpenVPN is connected.
This is the HTML element:
Every test creates new work order via API. So for every test work order title changes with a new workorder-title one, I leave DOM here to show DOM the design.
<div class="workorder-title">21-270073 / EM / -</div>
I found the problem. First of all everything, there were two different issues to solve about my Stackoverflow issue.
1- my API request came as unauthorized.
I was getting authorization tokens like this--> anyVariable=localStorage.getItem('autToken')
This was work without a problem while I using npx Cypress open because Cypress works extremely quickly on the interface and anyVariable fully filled by token and works without any problem.
But while using headless mode then cypress gets slower so that's why Cypress sent API req before anyVariable fully filled by token and responses as unauthorized.
I read some issues and articles about Cypress and Getting item by LocalStorage. People said that this usage "anyVariable=localStorage.getItem('autToken')" to get item local storage works as async So that's why I used cy. command to solve my problem and my attempt completely solved my problem.
I solved the problem by using the chainable cypress method.
cy.window()
.then((window) => {
return window.localStorage.getItem('anyVariable')
})
.then((token) => {
setAnyVariable(token)
})
2- The second problem was caused by one of our frontend component which refreshes the newly created item list to be newly created items visible. It was strange because that component was works stable when I run my tests with npx cypress open.
Why I explained that if you face with similar issue then you can try to check your frontend components.
I working on a solution to that problem right now.

Debugging JavaScript in client

I'm facing an issue while debugging my application. Following is the architecture:
Server: Java (Servlet)
Client: React+D3
Problem: Whenever, I change some react or d3 code and if an error occurs then it just shows me that some react (or d3) error has occurred but never tells me which function the error occurred (as seen in snapshot). Now, I know that simply debugging it by having the information like variable name and searching where I defined that variable. However, situation becomes tough when I use same object multiple times (say window) and had made several changes in the code. In this case, a specific line number where the error occured can be handy and quick. Let me know if I'm missing some basics about debugging such applications?
EDIT1:
1. In the snapshot, http://localhost:8080/..../Server Server is the main servlet application, kind of launchpad, which triggers several other react-based js files.
2. The mentioned ReferenceError is inside a function updateWindow() but the console never mentions this (and that's my problem).
PS: I'm using Eclipse tomcat on server-side
I think there's no straight forward solution to this problem. So, I'll post the method that worked for me with few additional points:
Problem: It doesn't gives a nice error trace like standard Java application, probably because it mixes with JavaScript code.
At every line of the error trace, line:column specifies the error line. I used this as a reference and started manual debugging from where my application launches i.e. Server.java and look where I defined the createChart() in the JS file and drill-down until I found the referenced variable.
In case of ReactJS' error (an error after resolving reference issue), I debugged it with normal react.js (not minified version react.min.js) so that it shows me exact line of error. Minified version is cluttered and is useless while debugging.
PS: If someone has better answer I'll edit this in future.

Getting 'unexpected mongo exit code 100' while running a meteor application

I am new to meteor .I started learning meteor language by referring a book
'My First Meteor Application'...While i was running my application i am getting a 'unexpected mongo exit code 100' error.It is showing 'unexpected mongo exit code 100 restarting'.help me get over this error
This error indicates that either mongo process is still running in the background or it was killed improperly. You may use
try `ps -A | grep 'mongo'
to see what's going on. Either way, in your .meteor/local/db directory, there will be a non-empty mongo.lock file. If there's an active mongo process, kill it and the file should become empty. Otherwise remove the file manually. When you're done the error should disappear.
This seems to be a common problem and there are multiple similar questions already out there with just as many suggested fixes. Problem is some of the proposed fixes either only work in certain cases or require using the meteor reset command which deletes the apps database(not ideal for everyone). I posted practically the same question a while back. I managed to solve it in my case and posted my answer to my own question here. It seems to have fixed the issue for several people already without the need for meteor reset so it's worth a try if you haven't found a fix yet. Good luck!

EmberJS Reset Warning: Library is already registered with Ember

Some background...
We have an ASP.NET app we're slowly converting over to EmberJS. We have a single Ember application we instantiate for certain portions of the site. As we migration pages they get routes in the Ember app. The goal is to have everything in Ember over time. In the interim, the user can click on links that take them back to ASP.NET portions.
Our issue is with resetting the state of the Ember app if the user either clicks back to go back into Ember or clicks on a new link that takes them back into the Ember portion.
We've tried calling .reset on the application, but doing so gives us an error saying the following. Our application is called ConsoleCli and not the standard App.
Library "ConsoleCli" is already registered with Ember
Moreover, we get the following error saying one of our modules has already been registered.
Cannot re-register: `location:history-js`, as it has already been resolved.
I tried wrapping my registration of the history module with a check, but that creates a whole other slew of errors
if(!application.__container__.lookup('location:history-js')){
application.register('location:history-js', HistoryJsLocation, { singleton: true });
}
I read https://github.com/emberjs/ember.js/issues/10310 and I think it means reset() is supposed to clear all registries once this has all been merged into the main branches.
Shouldn't called App.reset() right in the middle of using an EmberJS application just reset it with no issue?
Excuse my lack of understanding, we're just learning all of this as we go.
We're running the following versions
Ember 1.11.0-beta.2
Ember Data 1.0.0-beta.15
jQuery 2.0.3
TIA!
I think you might have run into this bug: https://github.com/emberjs/ember.js/issues/10310
Try the fix mutewinter suggests in that thread, it has worked for most people (involving myself).

Unable to implement JSNLog to ASP.NET MVC solution

After I installed and referenced the JSNLog package into my MVC project, I'm experiencing an error when ever I click a link.
For example,
Link
usually produce
Link
but after I start using the JSNLog, it now produce
Link
which will direct to a link
http://localhost:51745/jsnlog.logger?action=Bar&controller=Foo
which shows
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
I believe JSNLog is trying to send back a exception or log event back to the server whenever it has a chance to access the server.
Am I missing something to make this functional?
This bug existed when the original post was created, but it has been fixed a few version ago now (I am the author of JSNLog).
This is actually caused by the Ignore route they inject in App_Start, moving it into your routes collection manually fixes the issue. It happens because you don't manually define routes for the rest of the controllers, so .net tries to resolve to the first one it finds defined.
In App_Start\JSNLogConfig.cs take out
RouteTable.Routes.Insert(0, new Route("jsnlog.logger/{*pathInfo}", new StopRoutingHandler()));
In RouteConfig.cs add
routes.IgnoreRoute("jsnlog.logger/{*pathInfo}");
And all your other routes should start working fine.

Categories