Derbyjs Cannot call method expose of undefined - derbyjs

I want to extends query method of model, this is what i wrote:
store.query.expose('todos', 'forGroup', function(group) {
return this.where('group').equals(group);
});
but when i run the app, console says "Cannot call method expose of undefined", which means store.query is undefined.Why is that?
the store variable is:
var store = derby.createStore({
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})
, redis: redis
});
And i also output the store using console.log:
{ domain: null,
_events: { client: [Function] },
_maxListeners: 10,
racer:
{ get: [Function],
_plugins: [ [Function: derbyServer] ],
run: [Function: run],
createApp: [Function: createApp],
createStatic: [Function: createStatic] },
modelOptions: undefined,
shareClient:
{ options: { db: [Object], redis: [Object] },
preValidate: undefined,
validate: undefined,
backend:
{ snapshotDb: [Object],
getOps: [Function],
publish: [Function],
submit: [Function],
_subscribeChannels: [Function],
subscribe: [Function],
fetch: [Function],
bulkFetchCached: [Function],
fetchAndSubscribe: [Function],
queryFetch: [Function],
query: [Function],
collection: [Function],
destroy: [Function] },
extensions: { '': [] },
docFilters: [],
opFilters: [] },
logger: undefined }
and console.log(store.query) outputs undefined.

The Access Control Api was changed in the 0.5 version of Racer, which is mentioned here http://blog.derbyjs.com/2013/06/04/migrating-from-derby-0-dot-3-to-0-dot-5/
I have not played around that much with authentication, but a pointer is to look through the Auth example on GitHub - https://github.com/codeparty/derby-examples/tree/master/auth.

Related

Error: connect ECONNREFUSED 127.0.0.1:9001 in NextJS

When I tried running code on my local mission by npm run dev, I am getting these error, tried changing code as per error. When I tried to console data it showing unreachable to call, tried with some code changes but did not work. Initially there was autoprefixer error rectified it but now this error pops up not able to solve any suggestions will be appreciated
import {comps as newsComps} from 'ui-comps-news'
import {useEffect} from 'react'
import pageLoad from '../lib/pageLoad'
import UI from '../components/UI'
import PCMPreview from '../containers/PCMPreview'
import { useDispatch } from 'react-redux'
import {loadData} from '../actions';
export default function Index(props) {
const dispatch = useDispatch();
const elements = [];
Object.keys(newsComps).forEach(key => {
elements.push({key, value: newsComps[key]});
});
const layout = JSON.parse(props.dataStr);
const dataObj = {layout, elements, options: {}, styles: {}}
dispatch(loadData({layout: dataObj.layout}));
useEffect(() => {
PCMPreview.init({dispatch, data: dataObj});
}, []);
return <UI {...dataObj} />
}
export async function getServerSideProps(context) {
const { variant } = context.query;
const data = await pageLoad(variant);
return { props: { dataStr : console.log(JSON.stringify(data.layout)) } }
}
Error I am getting when running on localhost:3000:
Error: connect ECONNREFUSED 127.0.0.1:9001
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1133:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 9001,
config: {
url: 'http://localhost:9001/page?variant=undefined',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.21.1'
},
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
adapter: [Function: httpAdapter],
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: [Function: validateStatus],
data: undefined
},
request: <ref *1> Writable {
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: false,
emitClose: true,
autoDestroy: true,
errored: null,
closed: false,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError]
},
_eventsCount: 2,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: 10485760,
protocol: 'http:',
path: '/page?variant=undefined',
method: 'GET',
headers: [Object],
agent: undefined,
agents: [Object],
auth: undefined,
hostname: 'localhost',
port: '9001',
nativeProtocols: [Object],
pathname: '/page',
search: '?variant=undefined'
},
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [Socket],
_header: 'GET /page?variant=undefined HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'User-Agent: axios/0.21.1\r\n' +
'Host: localhost:9001\r\n' +
'Connection: close\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/page?variant=undefined',
_ended: false,
res: null,
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
_redirectable: [Circular *1],
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype]
},
_currentUrl: 'http://localhost:9001/page?variant=undefined',
[Symbol(kCapture)]: false
},
response: undefined,
isAxiosError: true,
toJSON: [Function: toJSON]
}
TypeError: Cannot read property 'layout' of undefined
at _callee$ (C:\Users\computer\Desktop\news-web\.next\server\pages\index.js:3664:58)
at tryCatch (C:\Users\computer\Desktop\news-web\node_modules\regenerator-runtime\runtime.js:63:40)
at Generator.invoke [as _invoke] (C:\Users\computer\Desktop\news-web\node_modules\regenerator-runtime\runtime.js:293:22)
at Generator.next (C:\Users\computer\Desktop\news-web\node_modules\regenerator-runtime\runtime.js:118:21)
at asyncGeneratorStep (C:\Users\computer\Desktop\news-web\.next\server\pages\index.js:3607:103)
at _next (C:\Users\computer\Desktop\news-web\.next\server\pages\index.js:3609:194)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

In protractor cucumber, getAttribute(Value) is returning Object (browser_, then, ...) instead of returning data

While trying to assert the date entered in the following web page getAttribute('value') returning "Object (browser_, then, ...)" instead of value .
https://material.angular.io/components/datepicker/examples
following is the snippet of code giving error
expect(element(by.xpath('//input[#id="mat-input-2"]')).getAttribute('value')).to.eventually.equal(element(by.xpath('//input[#id="mat-input-2"]')).getAttribute('value')).and.notify(callback);
For that i'm getting the following error
AssertionError: expected '1/6/2019' to equal { Object (browser_, then, ...) }
var date=element(by.xpath('//input[#id="mat-input-2"]')).getAttribute('value').getText();
console.log(date);
and the console.log for the above code is returning some thing like this.
ElementFinder {
browser_:
ProtractorBrowser {
controlFlow: [Function],
schedule: [Function],
setFileDetector: [Function],
getExecutor: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver:
Driver {
flow_: [ControlFlow],
session_: [ManagedPromise],
executor_: [Executor],
fileDetector_: null,
onQuit_: undefined,
getNetworkConnection: [Function],
setNetworkConnection: [Function],
toggleAirplaneMode: [Function],
toggleWiFi: [Function],
Please provide some solutions for this
Try that:
const elementOne = element(by.xpath('//input[#id="mat-input-2"]');
const elementTwo = element(by.xpath('//input[#id="mat-input-2"]');
return elementOne.getAttribute('value').then((elementOneValue) => {
return expect(elementTwo.getAttribute('value')).to.eventually.equal(elementOneValue).and.notify(callback);
});
Btw. Both elements got same selectors - they have to be equal.

read:ECONNRESET with Axios

I've encountered read:ECONNRESET error while I was trying to some data through axios post.
A configuration for Axios is
const http = require('http');
const https = require('https');
const axios = require('axios').create({
//keepAlive pools and reuses TCP connections, so it's faster
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),
});
function to send post request is
axios.post(`${HOST}/sendEmail/`, qs.stringify(params))
.then(() => {
if (conversation.managerUnreadCount) {
console.log('[todo] conversation.managerUnreadCount ', conversation.managerUnreadCount);
}
})
.catch((err) => {
console.error('err in axios', err, url);
});
Error is below..
{ Error: read ECONNRESET
at exports._errnoException (util.js:1020:11)
at TLSWrap.onread (net.js:580:26)
code: 'ECONNRESET',
errno: 'ECONNRESET',
syscall: 'read',
config:
{ adapter: [Function: httpAdapter],
transformRequest: { '0': [Function: transformRequest] },
transformResponse: { '0': [Function: transformResponse] },
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
validateStatus: [Function: validateStatus],
headers:
{ Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'axios/0.16.2',
'Content-Length': 737 },
httpAgent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object],
requests: {},
sockets: {},
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256 },
httpsAgent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: [Object],
freeSockets: [Object],
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache: [Object] },
method: 'post',
url: 'https://us-central1-customurl.cloudfunctions.net/sendEmail/',
data: 'fromEmail=testerA11%40mailinator.com&fromEmailName=tester%20A11&replyTo=testerA11%40msg.dev.hostthere.email&replyToName=tester%20A11&toEmail=hostthere.auth.test%40gmail.com&subject=test%20...*(custom data string here)*' },
request:
Writable {
_writableState:
WritableState {
objectMode: false,
highWaterMark: 16384,
needDrain: false,
ending: false,
ended: false,
finished: false,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function],
writecb: null,
writelen: 0,
bufferedRequest: null,
lastBufferedRequest: null,
pendingcb: 0,
prefinished: false,
errorEmitted: false,
bufferedRequestCount: 0,
corkedRequestsFree: [Object] },
writable: true,
domain: null,
_events:
{ response: [Function: handleResponse],
error: [Function: handleRequestError] },
_eventsCount: 2,
_maxListeners: undefined,
_options:
{ protocol: 'https:',
maxRedirects: 21,
maxBodyLength: 10485760,
hostname: 'us-central1-customurl.cloudfunctions.net',
port: null,
path: '/sendEmail/',
method: 'post',
headers: [Object],
agent: [Object],
auth: undefined,
nativeProtocols: [Object],
pathname: '/sendEmail/' },
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 737,
_requestBodyBuffers: [ [Object] ],
_onNativeResponse: [Function],
_currentRequest:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: false,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedHeader: [Object],
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: false,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'POST /sendEmail/ HTTP/1.1\r\nAccept: application/json, text/plain, */*\r\nContent-Type: application/x-www-form-urlencoded\r\nUser-Agent: axios/0.16.2\r\nContent-Length: 737\r\nHost: us-central1-customurl.cloudfunctions.net\r\nConnection: keep-alive\r\n\r\n',
_headers: [Object],
_headerNames: [Object],
_onPendingData: null,
agent: [Object],
... }
And in my system many different post requests are made at same time.
(not same url with above)
I thought if I added keep-alive options where axios created, but it did not help.
Any other ideas to resolve this error?
Thank you for reading.
I had the same problem. Turns out I was running script from a local machine that had intermittent Internet connection. Fixing the connection solved the issue.
check error log at api side.
In my case, it was error from api side which was throwing exception and its leading to this error.

Getting error on Watson Speech To Text using WebSocket

I'm receiving this error event from Watson Speech to Text when I try to pip the microphone input to it. Using NodeJS app based on this TJBot Code https://github.com/ibmtjbot/tjbot/tree/master/recipes/conversation
This is the error object that I get
=== Watson Speech to Text : An Error has occurred =====
_Event {
type: 'error',
isTrusted: false,
_yaeti: true,
target:
W3CWebSocket {
_listeners: {},
addEventListener: [Function: _addEventListener],
removeEventListener: [Function: _removeEventListener],
dispatchEvent: [Function: _dispatchEvent],
_url: 'wss://stream.watsonplatform.net/speech-to-text/api/v1/recognize?model=en-US_BroadbandModel',
_readyState: 3,
_protocol: undefined,
_extensions: '',
_bufferedAmount: 0,
_binaryType: 'arraybuffer',
_connection: undefined,
_client:
WebSocketClient {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
config: [Object],
_req: null,
protocols: [],
origin: null,
url: [Object],
secure: true,
base64nonce: 'XU/MDifsB9QqtrWn4vPFgw==' },
onerror: [Function],
onopen: [Function],
onclose: [Function],
onmessage: [Function] },
cancelable: true,
stopImmediatePropagation
: [Function] }
Press +C to exit.
This was working fine until some hours ago but suddenly stopped working. Any idea on what this error means ?
I just found my credentials were wrong. It seems that during migration to DIEGO the credentials at VCAP_SERVICES got deleted or something like that. I connected the services to the app again on Bluemix and the credentials got recreated

protractor console shows different than elementor console

element.all(by.css('td[data-header-text="products"]')).first()
productCountInTask = taskPage.productCountInTask.getText();
console.log("yyyy",taskPage.productCountInTask.getText());
this is code.
protractor console shows a long text
yyyy { ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver:
{ session_: [Object],
executor_: [Object],
flow_: [Object],
fileDetector_: null },
element: { [Function] all: [Function] },
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready:
{ closure_uid_815821442: 20,
flow_: [Object],
stack_: null,
parent_: null,
callbacks_: null,
state_: 'fulfilled',
handled_: true,
value_: null,
queue_: null },
plugins_:
{ pluginConfs: [],
pluginObjs: [],
assertions: {},
resultsReported: false },
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [ [Object], [Object], [Object] ],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
parentElementArrayFinder:
{ ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: [Object],
element: [Object],
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready: [Object],
plugins_: [Object],
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [Object],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
getWebElements: [Function],
actionResults_:
{ closure_uid_815821442: 7800,
flow_: [Object],
stack_: null,
parent_: [Object],
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null },
locator_:
{ using: 'css selector',
value: 'td[data-header-text="products"]' } },
then: [Function],
elementArrayFinder_:
{ ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: [Object],
element: [Object],
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready: [Object],
plugins_: [Object],
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [Object],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
getWebElements: [Function],
actionResults_:
{ closure_uid_815821442: 7800,
flow_: [Object],
stack_: null,
parent_: [Object],
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null },
locator_:
{ using: 'css selector',
value: 'td[data-header-text="products"]' } } }
bt when i do this in elementor console, it shows 2 as output. (it is a cell and i want cel value and it is 2)
element.all(by.css('td[data-header-text="products"]')).first().getText() 2
what am i doing wrong?
i tried different combinations but dd not work.
i think it is about output so when i do this
expect(element.all(
by.css('td[data-header-text="products"]')).first().getText()).toBe(1);
it says
Expected '1' to be 1.
i think it is because itis string , so i used Number to convert to int but did not work
Expected NaN to be 1.
it says for
expect(Number(element.all(by.css('td[data-header-text="products"]')).first().getText())).toBe(1);
so what to do
also for
var a = parseInt(element.all(by.css('td[data-header-text="products"]')).first().getText());
//checking if there is only one product
expect(a).toBe(1);
says
Expected NaN to be 1.
First of all protractor is asynchronous, so if you console log getText(), it will not give the text but a promise. Inorder to get the text, you should use then function() like:
taskPage.productCountInTask.getText().then(function(text){
console.log('yyyyy', text);
});