Crossbar.io autobahn: Error with session.subscribe (self2._defer is not a function) - wamp

Was trying to do a simple subscription to a topic inside my connection.onopen function, i.e.
session.subscribe(viewServerTx, (eventData) => {
console.log(viewServerTx, eventData);
numEl.innerText = `${eventData}`;
});
but this same error keeps appearing:
LiveViewsComponent.tsx:31 TypeError: self2._defer is not a function
at Session.subscribe (session.js:1350:17)
at connection2.onopen (LiveViewsComponent.tsx:45:15)
at self2._session.onjoin (connection.js:292:21)
at Session.self2._socket.onmessage (session.js:916:21)
at websocket.onmessage (websocket.js:112:23) 'Exception raised from app code while firing Connection.onopen()'
userError # LiveViewsComponent.tsx:31
For context,
connection is made successfully but fails to make the subscription
I am using a Vite React-Typescript app and importing the "autobahn" library
*Anyone has any idea as to what could be happening?

Related

How to check a cookie name is “not” present on page using Katalon Studio?

I need to check that a cookie is "NOT" present on-page.
Based on this post, I have tried the following on the scripted Katalon mode:
added these to the standard import from the test case:
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.WebDriver as WebDriver
then I wrote:
WebUI.verifyMatch(driver.manage().getCookieNamed('foo'), is(null()))
and then I get the following error on null pointer
FAILED Reason:
java.lang.NullPointerException: Cannot invoke method call() on null object
Is there a way to write a check on "none" existing cookies using the script mode for Katalon Studio?
P.S:
I have tried this other approach
try {
_fbp = driver.manage().getCookieNamed('_fbp').getName()
}
catch (Exception e) {
String _fbp = new String('Something went wrong')
System.out.println('Something went wrong')
}
WebUI.verifyMatch('Something went wrong', _fbp, false)
It fails only on the verifyMatch part. It seems that 'something went wrong' does not really get stored in the variable _fbp.
FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: _fbp for class:
WebUI.verifyMatch() is used for checking matching between two strings.
You can do that using the plain Groovy assert. Instead of
WebUI.verifyMatch(driver.manage().getCookieNamed('foo'), is(null()))
do this:
assert driver.manage().getCookieNamed('foo').is(null)

Ionic 3 Infinite Scroll 'cannot read property timestamp of null'

So I am using infinite scroll to load a very large reactive form in bits.
However I've noticed that if a form input event is triggered while the infinite scroll is loading other items this happens.
ERROR TypeError: Cannot read property 'timeStamp' of null
at InfiniteScroll._onScroll (infinite-scroll.js:229)
at SafeSubscriber.schedulerFn [as _next] (core.es5.js:3647)
at SafeSubscriber.__tryOrUnsub (Subscriber.js:238)
at SafeSubscriber.next (Subscriber.js:185)
at Subscriber._next (Subscriber.js:125)
at Subscriber.next (Subscriber.js:89)
at EventEmitterProxy.Subject.next (Subject.js:55)
at EventEmitterProxy.EventEmitter.emit (core.es5.js:3621)
at ScrollView.scroll.onScroll (content.js:378)
at ScrollView.setScrolling (scroll-view.js:52)
at ScrollView.scrollTo (scroll-view.js:401)
at Content.scrollTo (content.js:433)
at TextInput._jsSetFocus (input.js:524)
at TextInput._pointerEnd (input.js:496)
at Object.eval [as handleEvent] (TextInput.ngfactory.js:130)
at Object.handleEvent (core.es5.js:11998)
at Object.handleEvent (core.es5.js:12717)
at dispatchEvent (core.es5.js:8614)
at core.es5.js:9228
at HTMLDivElement.<anonymous> (platform-browser.es5.js:2648)
at HTMLDivElement.wrapped (raven.js:350)
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.es5.js:3881)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at e.invokeTask [as invoke] (polyfills.js:3)
at p (polyfills.js:2)
at HTMLDivElement.v (polyfills.js:2)
console.(anonymous function) # console.js:32
defaultErrorLogger # core.es5.js:1020
ErrorHandler.handleError # core.es5.js:1080
IonicErrorHandler.handleError # ionic-error-handler.js:61
webpackJsonp.381.SentryErrorHandler.handleError # sentry-
errorhandler.ts:11
(anonymous) # core.es5.js:9232
(anonymous) # platform-browser.es5.js:2648
wrapped # raven.js:350
t.invokeTask # polyfills.js:3
onInvokeTask # core.es5.js:3881
t.invokeTask # polyfills.js:3
r.runTask # polyfills.js:3
e.invokeTask # polyfills.js:3
p # polyfills.js:2
v # polyfills.js:2
It's really driving me crazy because not even a try catch can stop this error from crashing the app.
Please I need help!!
This is a current ionic issue, that unfortunately doesn't look like it will be patched before v4.
bug(infinite-scroll): throws uncatchable error if scrollToTop is called before it is resolved
The quickest way to try and avoid the issue (it doesn't work everytime) is to wrap a setTimeout around the scrollToTop / scrollToBottom
setTimeout(function(){
this.content.scrollToBottom()
},200);
I was experiencing a similar issue, ran into this:
TypeError: Cannot read property 'enableEvents' of null
at EventEmitterProxy.enableScrollListener [as onSubscribe]
This would happen intermittently after a function on a different Ionic page that refreshed external content within our app. I never figured out exactly why, but I noticed that it was only happening when the infinite-scroll had been triggered at some point during user interaction with the original page.
In our case, I was setting the InfiniteScroll instance to a local, component-level variable so that I could use the .enable() hooks programmatically in other functions, like so:
VIEW:
<ion-infinite-scroll (ionInfinite)="lazyLoad($event)"> ...
CONTROLLER:
public lazyLoad(infiniteScroll: InfiniteScroll) {
// ASSIGN THE LAZY LOADER INSTANCE ON FIRST RUN SO IT CAN BE ENABLED / DISABLED ELSEWHERE
this.lazyLoader = infiniteScroll;
....
}
But, then we would run into the above TypeError randomly when refreshing content, so it was almost like there was a call somewhere trying to reference that variable. So I just set the variable to null when the page left the view, and now it works. Weirdness.
(NOTE: all calls to the instance of InfiniteScroll were wrapped in an if (this.lazyLoader && this.lazyLoader !== null) gate to begin with so I'm not really sure what went wrong)
ionViewWillLeave() {
this.lazyLoader = null;
}
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
#Component({...})
export class MyPage{
scrollToTop() {
this.navCtrl.setRoot('MyPage'); //so you will go to the top of page.
}
}
Go to infinite-scroll.js
Check if ev is null
If null return 3;
//Do nothing

Qunit assert throws not working

I am trying to assert that a few steps in the code (visiting page, providing wrong card-number, password combination and clicking submit)should generate an error from the backend service - I have referred to this already..
and tried the suggestion of using Error Object as the second argument to assert.throws but that doesn't work for me.
i did see this link as well before posting my question,
My problem is - I don't have control over the code that throws the exception/error in this case. (I cannot change it to say Ember.assert etc) I just want to be able to catch an erroneous case.
Secondly, I don't have a component in this case. Its a straight forward API call that's made when click on submit is done, basically an action submitAuthForm is called in controller which calls ember cli mirage scenario that returns the following object problems object.
return new Response(401,{'X-Auth-Token': 'wrong-username-password-combination'},failResponse401);
and the returned object looks like
var failResponse401 = {
problems: [ {
field: null,
index: null,
value: null,
code: '0006',
subCode: '',
details: {},
_type: 'error'
} ]
};
We have a node_module dependency on an in-house exceptions kit that throws an Error object based on this.
Here's my Qunit test
test('ERROR_CASE_visiting /signon, provide cardNumber(2342314) and ' +
'password, submit and expect to see invalid cardnumber/password error',
function (assert) {
assert.expect(2);
assert.throws(
function () {
visit('/signon');
fillIn('#a8n-signon-card-number input', '2342314');
fillIn('#a8n-signon-password input', 'password');
click('#a8n-signon-submit-button button');
},
Error,
"Error Thrown"
);
});
I keep getting this error from Qunit
Error Thrown# 110 ms
Expected:
function Error( a ){
[code]
}
Result:
undefined
Diff:
function Error( a ){
[code]
}defined
Source:
at Object.<anonymous> (http://localhost:7357/assets/tests.js:175:12)
at runTest (http://localhost:7357/assets/test-support.js:3884:30)
at Test.run (http://localhost:7357/assets/test-support.js:3870:6)
at http://localhost:7357/assets/test-support.js:4076:12
at Object.advance (http://localhost:7357/assets/test-support.js:3529:26)
at begin (http://localhost:7357/assets/test-support.js:5341:20)
API rejected the request because of : []# 1634 ms
Expected:
true
Result:
false
Source:
Error: API rejected the request because of : []
at Class.init (http://localhost:7357/assets/vendor.js:172237:14)
at Class.superWrapper [as init] (http://localhost:7357/assets/vendor.js:55946:22)
at new Class (http://localhost:7357/assets/vendor.js:51657:19)
at Function._ClassMixinProps.create (http://localhost:7357/assets/vendor.js:51849:12)
at Function.createException (http://localhost:7357/assets/vendor.js:172664:16)
at Class.<anonymous> (http://localhost:7357/assets/vendor.js:133592:72)
at ComputedPropertyPrototype.get (http://localhost:7357/assets/vendor.js:32450:27)
at Object.get (http://localhost:7357/assets/vendor.js:37456:19)
at Class.get (http://localhost:7357/assets/vendor.js:50194:26)
at http://localhost:7357/assets/vendor.js:133645:30
Is there anything else that i can try to get it to work.
Is there someway i could somehow pass this test, by wrapping the returned response somehow in a way that it doesn't break my test altogether.
I found a workaround following this link
the user pablobm has posted a link to a helper
I used that to workaround this Qunit issue.

Handling typeError through Ember.onerror

I would like to be able to be able to handle javascript errors in my Ember application and display a generic modal defined in my application's templates. I'm able to process errors by defining a function for Ember.onerror, but haven't been able to find a way to trigger an event or action against my application for certain error types, for instance a TypeError.
Below is a sample of how I've approached defining Ember.onerror
App.report_errors = (error) ->
console.log "error", error
# Would like to be able to use something like the below line
# to call an action on the application route
#send "showError"
# Log to api
Em.onerror = App.report_errors
Here is a full example fiddle illustrating what I would like to accomplish: http://jsfiddle.net/mandrakus/c8E3x/1/
Thanks!
This solution (courtesy Alex Speller) adds an errorReporter object which is injected during initialization with the ability to access the router and therefore router actions.
App.initializer
name: 'errorReporter'
initialize: (container) ->
container.injection 'reporter:error', 'router', 'router:main'
container.injection 'route', 'errorReporter', 'reporter:error'
reporter = container.lookup 'reporter:error'
Em.onerror = (error) ->
reporter.report error
App.ErrorReporter = Em.Object.extend
report: (error) ->
console.log "error", error
#Would like to be able to use something like the below line
#to call an action on the application route
#router.send "showError"
App.ApplicationRoute = Ember.Route.extend
actions:
error: (error) -> #errorReporter.report error
showError: ->
console.log "displaying error"
#the final application generate a modal or other notification
alert "Generic Error Message"
How about this?
App.report_errors = function (error) {
App.__container__.lookup("route:application").send("showError", error);
};
Two potential problems:
Using global App object. Not a big deal, unless you're trying to host two ember apps side-by-side
Using the hidden container property. This might change name/location in the future, but as I see it used all over the place, I doubt Ember team will remove it completely.

Controller Unit Test fails with SQLSTATE[42000] error

I want to unit test a controller action and have some problem toio excecute it.
The Error i got is the following:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'questionExists'
at line 1
The Method:
questionExists
is defined inside the Question Model.
My test function looks like this:
public function testView() {
$result = $this->testAction('/questions/questions/view/1', array('return' => 'vars'));
}
The Controller action i want to test looks like this:
public function view($id = null) {
if (!$this->Question->questionExists($id, 'id_virtual')) {
throw new NotFoundException(__('Invalid question'));
}
$options = array('conditions' => array('Question.id_virtual' => $id));
$this->set('question', $this->Question->find('first', $options));
}
So this is very confusing to me.
Can anybody point me to the right direction ?
Your model class is not found, CakePHP creates an instance on the fly for that table but this is not more than the basic Model class. When the code is then called it tries to call that method on an instance that is not your Question model in your app. You'll have to figure out what that happens.