Salesforce, lwc local development server crashing - salesforce

Starting LWC Local Development.
Username: test-lgcvzacysqx3#example.com
Api Version: 49.0
[HPM] Proxy created: / -> https://ability-customization-2906-dev-ed.my.salesforce.com
[HPM] Subscribed to http-proxy events: [ 'proxyReq', 'error', 'close' ]
cp: no such file or directory: /Users/admin/Desktop/suman/force-app/main/default/staticresources/*
cp: no such file or directory: /Users/admin/Desktop/suman/force-app/main/default/contentassets/*
LWR6003: Listening on :3333
Server up on http://localhost:3333
LWR6000: Created version hash "f5aff7264b"
LWR6001: Writing /Users/admin/Desktop/suman/.localdevserver/webruntime/custom-component/f617504cf1/dev/en-GB/c/myfirstLwc.js...
LWR6001: Writing /Users/admin/Desktop/suman/.localdevserver/webruntime/custom-component/f617504cf1/dev/en-GB/c/myfirstLwc.js...
CLIError: timed out
at Object.error (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/errors/index.js:28:15)
at /Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:25:66
at async flush (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:121:9) {
oclif: { exit: 2 },
code: undefined
}
CLIError: timed out
at Object.error (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/errors/index.js:28:15)
at /Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:25:66
at async flush (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:121:9) {
oclif: { exit: 2 },
code: undefined
}
LWR6004: Server is shutdown
Error: timed out
at Object.error (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/errors/index.js:28:15)
at /Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:25:66
at async flush (/Users/admin/.local/share/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux/index.js:121:9)
10:01:49.554 sfdx force:lightning:lwc:start
ended with exit code 1
Error: The local development server exited unexpectedly with code 1.

I faced the similar error today
But somehow made it running using the below solution
Open the below path
C:/Users/UserName/AppData/Local/sfdx/client/7.163.0-ea5a9c6/node_modules/#oclif/core/lib/cli-ux
And edit the async flush() method in the index.js file
from 10000 to 600000
await timeout(flush(), 600000);
Hope this helps.
found some articles here for help

Related

Truffle Migrate base fee exceeds gas limit

While trying to deploy contracts locally I am getting the below error.
Error: *** Deployment Failed ***
"ABCContract" -- Returned error: base fee exceeds gas limit.
I have tried to manipulate the gas in Ganache GUI but this error is still occurring. Below is my truffle config.
require('babel-register')
require('babel-polyfill')
module.exports = {
networks: {
development: {
host: '127.0.0.1',
port: 7545,
network_id: '*', // Match any network id
},
},
contracts_directory: './src/contracts/',
contracts_build_directory: './src/abis/',
compilers: {
solc: {
version: '0.8.9',
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: 'petersburg',
},
},
}
In Ganache I have set GAS LIMIT: 6721975 and GAS PRICE: 20000000000
UPDATE
It turns out that if I remove some of my methods I am able to deploy the contract but apart from that I am getting the above error.
Another Update
I got the main reason why this error is occurring. It is because I am using mint function in my constructor and that mint is causing this problem. When I commented that function the problem is solved. Don't know why but it is causing the problem.
Last and final update
Turns out it was a programming mistake. I called the mint function inside the mint function instead of the ERC _mint function and it goes into recursion forever which caused this problem.

Websocket handshake error in React after yarn upgrade

In my react app, I connect to some websockets using the websocket package (not socket.io)
componentDidMount(): void {
this.settingsSubscription = subscribeToWebsocket("Settings", urls.SETTINGS_WS, handleSettingsMessage);
this.statusSubscription = subscribeToWebsocket("Status", urls.STATUS_WS, handleStatusMessage);
this.studyDataSubscription = subscribeToWebsocket("Study Data", urls.STUDY_WS, handleStudyDataMessage);
}
subscribeToWebsocket(name, url, messageHandler): W3CWebSocket {
let subscription = new W3CWebSocket(url);
subscription.onopen = () => console.log(`WebSocket Client Connected (${name})`);
subscription.onclose = () => console.log(`WebSocket Client Disconnected (${name})`);
subscription.onmessage = messageHandler;
return subscription;
}
This had been working fine, and in fact does still work fine except I also get this error in the console:
WebSocket connection to 'ws://localhost:3000/sockjs-node' failed:
Error during WebSocket handshake: Unexpected response code: 200
./node_modules/react-dev-utils/webpackHotDevClient.js # webpackHotDevClient.js:51
__webpack_require__ # bootstrap:785
fn # bootstrap:150
1 # helpers.ts:1
__webpack_require__ # bootstrap:785
checkDeferredModules # bootstrap:45
webpackJsonpCallback # bootstrap:32
(anonymous) # index.chunk.js:1
The error points to these lines in node-modules/react-dev-utils/webpackHotDevClient.js which appear to be the culprit:
// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
url.format({
protocol: 'ws',
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
})
);
I had just run yarn upgrade --latest --exact so I'm guessing that has something or other to do with it.
Especially since we use the console to demo to the client, I'd really love to get rid of this error message. Thanks!
we had same issue with ejected CRA project.
Solution of mine is manual update of the config/webpackDevServer.config.js config file.
Imho this changes are the reason our livereload works again:
hot: true,
+ // Use 'ws' instead of 'sockjs-node' on server since we're using native
+ // websockets in `webpackHotDevClient`.
+ transportMode: "ws",
+ // Prevent a WS client from getting injected as we're already including
+ // `webpackHotDevClient`.
+ injectClient: false,
// It is important to tell WebpackDevServer to use the same "root" path
I had the same issue when developing an azure portal extension on my localhost. I changed 'ws' to 'wss' and it worked.

test case execution is getting failed and it is throwing any error stack trace in command line

I created a testcase with Protractor-cucumber framework and I have used Grunt for execution of that test case. However, at the time of execution it failed and it's not providing any error stacktrace to know why it is failing.
I've searched Google and also reviewed other Stack Overflow solutions but I didn't find a solution for this.
Config File
exports.config = {
//seleniumAddress: 'http://localhost:4444/wd/hub',
getPageTimeout: 60000,
allScriptsTimeout: 500000,
directConnect:true,
framework: 'custom',
// path relative to the current config file
frameworkPath: require.resolve('C:\\...\\node_modules\\protractor-cucumber-framework'),
capabilities: {
'browserName': 'chrome'
},
ignoreUncaughtExceptions:true,
// Spec patterns are relative to this directory.
specs: [
'./learnFramework/utility/test.feature'
],
cucumberOpts: {
require: './learnFramework/TestCases/spec.js',
tags: false,
profile: false,
'no-source': true
},
onPrepare: function () {
browser.ignoreSynchronization=true;
browser.manage().window().maximize();
}
};
Spec File
module.exports=function(){
this.Given(/^Open the browser and Load the URL$/,async function(){
browser.get("https://google.com");
});
this.When(/^User entered the text in the search box$/,async function(){
browser.sleep(5000);
console.log(await browser.getTitle());
await element(By.name("q")).sendKeys("facebook");
browser.sleep(3000);
});
this.Then(/^click on search$/,async function(){
browser.action().sendKeys(protractor.Key.ENTER).perform();
browser.sleep(5000);
});
}
Error Log
Running "jshint:files" (jshint) task
>> 1 file lint free.
>
Running "protractor:singlerun" (protractor) task
[00:08:29] I/launcher - Running 1 instances of WebDriver
[00:08:29] I/direct - Using ChromeDriver directly...
>
DevTools listening on ws://127.0.0.1:50146/devtools/browser/5c09d68c-f3ff-43b2-b645-0b5c098c41d9
Feature: Title of your feature
>
I want to use this template for my feature file
>
Scenario: Title of your scenario
✓ Given Open the browser and Load the URL
✖ When User entered the text in the search box
- And click on search
>
Failures:
>
[00:09:03] I/launcher - 0 instance(s) of WebDriver still running
[00:09:03] I/launcher - chrome #01 failed 1 test(s)
[00:09:03] I/launcher - overall: 1 failed spec(s)
[00:09:03] E/launcher - Process exited with error code 1
>>>
>>> Test failed but keep the grunt process alive.
>
Done.
If you observe the error log "When" step has failed but there is no error stacktrace in the command line to find why it failed.
My expectation is that it should show the error stacktrace for why it has failed.
You need to use await on your browser actions otherwise it performs the actions synchronously.
e.g
await browser.get("https://google.com");

Artillery: How can I mark a test scenario as failed using artillery load test and show the same in some report?

I am working on some test requirement where I have to fail a load test scenario when p95>100ms. I have written below test snippet:
config:
target: "https://news.google.com"
# Responses have to be sent within 10 seconds or the request will be aborted
timeout: 10
ensure:
p95: 800
phases:
- duration: 10
arrivalRate: 1
scenarios:
- name: "Hit news google"
flow:
- get:
url: "/dssw.js_data?_reqid=34556&rt=j"
expect:
- statusCode: 300
- contentType: json
I want this test scenario to be visible in some kind of reports as how many test case has been failed and pass. Artillery generates the report only showing the performance stats but how to show the report as per the test performance assertion failed in some kind of report.
One option is to implement a hook in javascript that looks at the status code and if deems the status as failed returns an error trough the next function.
Example js hook function:
function exitOnFail(requestParams, response, context, ee, next) {
const statusCode = parseInt(response.statusCode);
if (statusCode > 399) {
next(new Error(`${requestParams.url} StatusCode: ${statusCode}`));
} else {
next();
}
}
and connecting the hook to the request:
config:
...
processor: './scriptfile.js'
...
scenarios:
- flow:
- get:
url: some/url
...
afterResponse: 'exitOnFail'

MEAN RESTful application error handling server crashes

I've just followed a tutorial for creating a simple RESTful api using the MEAN stack from the heroku webpage. What I did was just cloning the repo that contains the sample code, added my mongodb_uri from mLab and then run the app locally (npm start).
It works perfectly, but when I try to make an invalid entry (not providing name and last name to a contact) the express server crashes and the entry is made on my database (which is inconsistent).
I've opened an issue on the github repo but I got no answers, I think that there must be something wrong with the error handling but I don't know what it might be.
Here it is what I get when the server crashes:
ERROR: Invalid user input
/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:98
process.nextTick(function() { throw err; });
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
at ServerResponse.header (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:719:10)
at ServerResponse.send (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:164:12)
at ServerResponse.json (/Users/nanop/Desktop/mean-contactlist/node_modules/express/lib/response.js:250:15)
at /Users/nanop/Desktop/mean-contactlist/server.js:72:23
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:421:18
at handleCallback (/Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/utils.js:96:12)
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb/lib/collection.js:726:5
at /Users/nanop/Desktop/mean-contactlist/node_modules/mongodb-core/lib/connection/pool.js:428:18
at nextTickCallbackWith0Args (node.js:433:9)
And finally this is the handleError method defined which I think it's ok:
function handleError(res, reason, message, code) {
console.log("ERROR: " + reason);
res.status(code || 500).json({"error": message});
}
This is the repo I refer to: https://github.com/chrisckchang/mean-contactlist

Resources