How to use #sentry/node in razzle express server file - javascript

According to sentry's docs the setup for node is just
// server.js
const Sentry = require("#sentry/node");
Sentry.init({ dsn: "https://1df8da5e900e440e8d6e767ec6277ff9#o126849.ingest.sentry.io/296346" });
However, when I run razzle start I get this
TypeError: mod.require is not a function
at dynamicRequire (/Users/daniellizik/foo/node_modules/#sentry/utils/esm/node.js:19:1)
at getDefaultSamplingContext (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/tracing/esm/hubextensions.js:107:1)
at Hub._startTransaction (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/tracing/esm/hubextensions.js:162:1)
at Hub.module.exports../node_modules/#sentry/hub/esm/hub.js.Hub._callExtensionMethod (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/hub/esm/hub.js:348:1)
at Hub.module.exports../node_modules/#sentry/hub/esm/hub.js.Hub.startTransaction (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/hub/esm/hub.js:308:1)
at callOnHub (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/minimal/esm/index.js:17:1)
at startTransaction (/Users/daniellizik/foo/build/webpack:/node_modules/#sentry/minimal/esm/index.js:189:1)
There is a closed issue in the sentry repo for universal apps, but no solution is provided.

These deps seem to work now with universal js apps
"#sentry/browser": "6.8.0",
"#sentry/node": "6.8.0",
"#sentry/tracing": "6.8.0"

Related

How to access feature files in cucumber using Cypress latest version (10.2.20)

I have been working on Cypress's latest version (10.2.0) with BDD in cucumber. Everything's working fine just my feature files are not accessible. I have tried using SpecPattern as written in the documentation but no help.
The spec pattern line is as follows:
specPattern: "/cypress/e2e/**/*.feature"
Also, My cucumber is imported and running fine
Cypress.config file:
const { defineConfig } = require("cypress");
const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('file:preprocessor',cucumber())
// implement node event listeners here
},
Package.Json File:
"devDependencies": {
"cypress-cucumber-preprocessor": "^4.3.1"
},
"cypress-cucumber-preprocessor":{
"nonGlobalStepDefinitions" : false
}
}
Image showing there is no feature file in this directory
While my feature file is present in the same directory shown in the above picture
Any help would be appreciated
You should change your cypress-cucumber library.
This indicates you have an old version
const cucumber = require('cypress-cucumber-preprocessor').default
You should use this version
// package.json
"#badeball/cypress-cucumber-preprocessor": "^11.3.0",
// cypress.config.js
const preprocessor = require("#badeball/cypress-cucumber-preprocessor");
Repo, instructions etc Github
Update your specPattern to "**/*.feature". This will search for .feature files throughout your project and not just a specific folder.

Uncaught Error: Cannot add node "1" because a node with that id is already in the Store

I can't debug in react-native using the react-native debugger
Uncaught Error: Cannot add node "1" because a node with that id is already in the Store.
C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48 Uncaught Error: Cannot add node "1" because a node with that id is already in the Store.
at C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48
at c.emit (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48)
at C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48
at C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48
at Array.forEach (<anonymous>)
at S.Gc.e.onmessage (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:48)
at S.n (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:40)
at S.emit (events.js:315)
at e.exports.P (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:8)
at e.exports.emit (events.js:315)
at e.exports.dataMessage (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:8)
at e.exports.getData (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:8)
at e.exports.startLoop (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:8)
at e.exports._write (C:\Users\kbelhadjali\AppData\Local\react_native_debugger\app-0.12.1\resources\app.asar\node_modules\react-devtools-core\dist\standalone.js:8)
at doWrite (_stream_writable.js:403)
at writeOrBuffer (_stream_writable.js:387)
and when i tried to use the debugger-ui only it doesn't work aswell and showing me this error:
Development Tools failed to load source map: Unable to load content from http: // localhost: 19000 / debugger-ui / debuggerWorker.aca173c4.js.map: Failed to retrieve via target: Target not taken in charge ; Fallback: HTTP error: status code 404, net :: ERR_HTTP_RESPONSE_CODE_FAILURE
i even created a blank project to test if the problem is caused by my project but it didn't work aswell showing me the same errors.
Any help would me much appreciated.
I also had this problem, my dependencies:
...
"expo": "~43.0.0",
"react": "17.0.2",
"react-native": "0.66.3"
Seems like "react-devtools-core" in react-native dependencies install old package version.
I added
"resolutions": {
"react-devtools-core": "4.14.0"
}
To package.json for solving this problem.
I also reinstall last react-native-debugger ( brew reinstall react-native-debugger)
Maybe it will help you.

Cannot use namespace 'Boom' as a type

I am using hapi for one of my node+typescript project. I am trying to update hapi to the new #hapi/hapi package, due to the deprecation of the "naked" packages. I've changed #types/hapi to #types/hapi__hapi.
As soon as I updated, I started getting the TypeScript error -
node_modules/#types/hapi__hapi/index.d.ts:514:32 - error TS2709: Cannot use namespace 'Boom' as a type.
514 response: ResponseObject | Boom;
~~~~
node_modules/#types/hapi__hapi/index.d.ts:4050:18 - error TS2709: Cannot use namespace 'Boom' as a type.
4050 (Error | Boom) |
~~~~
Found 2 errors.
Here's the dependencies I have in package.json -
{
...
"devDependencies": {
...
"#types/hapi__boom": "7.4.1",
"#types/hapi__hapi": "18.2.5",
"#types/hapi__joi": "16.0.1",
"#types/nock": "10.0.3",
"#typescript-eslint/eslint-plugin": "2.4.0",
"jest": "24.9.0",
"nock": "11.4.0",
"nodemon": "1.19.4",
"prettier": "1.18.2",
"typescript": "3.6.4"
},
"dependencies": {
...
"#hapi/boom": "8.0.1",
"#hapi/hapi": "18.4.0",
"#hapi/joi": "16.1.7",
"axios": "0.19.0",
"axios-retry": "3.1.2"
},
...
}
I checked the node_modules/#types/hapi__hapi/index.d.ts file and it was importing Boom using the following way -
import * as Boom from '#hapi/boom';
When I change it to
import { Boom } from '#hapi/boom';
and it solved the error.
I can't change the index.d.ts file, as it's from #types/hapi__hapi package, but I want to solve this issue. Is there anything I can do to not have this error, such as downgrading to some specific version?
I checked the issues at #hapi/boom and they included types in 7.x release which were breaking typescript build. They removed types from 7.x releases, but put them back in 8.x, and since I was using #hapi/boom 8.0.1, it was conflicting with the existing types.
All the hapi ecosystem is going to include type definitions in them, but other packages are not updated to do it (as far as I could tell), thus the only way to resolve this issue without breaking breaking TypeScript builds is to downgrade #hapi/boom to 7.4.11.
PS: I found out the github issues minutes after posting the question, but I am still open for better answers, if there is one.

Test two different npm package versions at the same time

When I create an npm package, sometimes it would face the need to backward old dependency package version.
If the new version has new api, I may write the code in this pattern:
import pkg from 'some-pkg';
const isNewVersion = pkg.newVersionApi !== 'undefined';
if (isNewversion) {
pkg.newVersionApi();
} else {
pkg.oldVersionApi(); // backward compatible api
}
And with this pattern, when I want to write the test, I only can test the installed version code. The other version's code can't be tested.
For real example, in React v15 and v16, React v16 has new API Portal. Before Portal release, v15 has unstable_renderSubtreeIntoContainer api to realize similar feature.
So the code for React would be like:
import ReactDOM from 'react-dom';
const isV16 = ReactDOM.createPortal !== 'undefined';
if (isV16) {
ReactDOM.createPortal(...);
} else {
ReactDOM.unstable_renderSubtreeIntoContainer(...);
}
So I want to ask is there any method to test with different dependency version?
Currently, one method I think of is to install the other version again and test it. But it only can do on local. It can't work on ci and it can't count in coverage together.
I think that is not only for react test. It may face on node.js test. Any suggestion can be discussed.
Updated
This question maybe is related to install two versions dependency in npm. But I know currently installing two versions dependency is not workable.
Here is a might be solution, not sure it will work as you expect. But, you will have a direction to move forward.
package.json
{
"name": "express-demo",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.3",
"express": "~4.15.2",
"jade": "~1.11.0",
"morgan": "~1.8.1",
"serve-favicon": "~2.4.2",
"webpack": "^3.8.1",
"webpack-dev-middleware": "^1.12.0",
"webpack-hot-middleware": "^2.20.0"
},
"customDependecies": {
"body-parser": [
"",
"1.18.1",
"1.18.0"
]
}
}
Note in above package.json file, I have added a new key customDependecies which I will use for installing multiple dependencies. Here I am using body-parser package for demo. Next you need file, that can read this key and install the deps.
install-deps.js
const {spawnSync} = require('child_process');
const fs = require('fs');
const customDependencies = require('./package.json').customDependecies;
spawnSync('mkdir', ['./node_modules/.tmp']);
for (var dependency in customDependencies) {
customDependencies[dependency].forEach((version) => {
console.log(`Installing ${dependency}#${version}`);
if (version) {
spawnSync('npm', ['install', `${dependency}#${version}`]);
spawnSync('mv', [`./node_modules/${dependency}`, `./node_modules/.tmp/${dependency}#${version}`]);
} else {
spawnSync('npm', ['install', `${dependency}`]);
spawnSync('mv', [`./node_modules/${dependency}`, `./node_modules/.tmp/${dependency}`]);
}
});
customDependencies[dependency].forEach((version) => {
console.log(`Moving ${dependency}#${version}`);
if (version) {
spawnSync('mv', [`./node_modules/.tmp/${dependency}#${version}`, `./node_modules/${dependency}#${version}`]);
} else {
spawnSync('mv', [`./node_modules/.tmp/${dependency}`, `./node_modules/${dependency}`]);
}
});
}
spawnSync('rm', ['-rf', './node_modules/.tmp']);
console.log(`Installing Deps finished.`);
Here, I am installing deps one by one in tmp folder and once installed, I am moving them to ./node_modules folder.
Once, everything is installed, you can check the versions like below
index.js
var bodyParser = require('body-parser/package.json');
var bodyParser1181 = require('body-parser#1.18.1/package.json');
var bodyParser1182 = require('body-parser#1.18.0/package.json');
console.log(bodyParser.version);
console.log(bodyParser1181.version);
console.log(bodyParser1182.version);
Hope, this will serve your purpose.
Create 3 separate projects (folders with package.json) and a shared folder:
A shared folder containing the test module (my-test). Export a function to run the test;
A client project importing my-test and dependency v1. Export a function that calls the test function in my-test.
A client project importing my-test and dependency v2. Export a function that calls the test function in my-test.
A master project that imports both client projects. Run each exported function.
You're going to have to run them separately. Create a separate project folder for each dependency version. Ex. React10, React11, React12. Each will have its own package.json, specified for the correct version. When you run the integration and/or versioned tests, you'll run your standard unit tests across each version, but it may also be advisable to add any version specific unit tests to that folder.
Creating a make file would make your life easier when running your full testing suite. If you do this you can easily integrate this into CI.
In addition to the other suggestions, you can try the approach described at Testing multiple versions of a module dependency.
Here's an example of using this approach to test against multiple webpack versions:
npm install --save-dev module-alias
npm install --save-dev webpack-v4#npm:webpack#4.46.0
npm install --save-dev webpack-v5#npm:webpack#5.45.1
The module-alias package handles the magic of switching between package versions while still supporting normal require('webpack') (or whatever your module is) calls.
The other installs will create two versions of your dependency, each with a distinct directory name within your local node_modules/.
Then, within your test code, you can set up the dependency alias via:
const path = require('path');
require('module-alias').addAlias(
'webpack',
path.resolve('node_modules', 'webpack-v4'),
);
// require('webpack') will now pull in webpack-v4
You'd do the same thing for 'webpack-v5' in a different test harness.
If any of your sub-dependencies have a hardcoded require('webpack') anywhere in their own code, this will ensure that they also pull in the correct webpack version.

EmberJs: 404 GET http://localhost:4200/assets/my-app.css

I will preface this by saying I am very new to using Ember (1 week) and JS frameworks in general but have been developing .Net WebAPIs and building by own JS front ends for a few years.
I've looked everywhere and can't seem to find any clues on how to debug this issue. I recently integrated Semantic-UI into my app and was able to use it fine for a little while. However, this morning my application started throwing a 404 when trying to access the bundled stylesheet.
I've tried reverting to previous versions and I've even run ember init neither of which resolved the issue.
Currently, I am trying to just create a new app, but am facing issues on that front as well...
$ ember version
version: 1.13.8
node: 0.12.7
npm: 2.13.4
os: win32 x64
bower.json:
"dependencies": {
"ember": "1.13.7",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.13.8",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5",
"ember-qunit": "0.4.9",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.18",
"jquery": "^1.11.3",
"loader.js": "ember-cli/loader.js#3.2.1",
"qunit": "~1.18.0",
"semantic-ui": "~2.0.8"
}
EDIT:
Below is my ember-cli-build.js file:
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
lessOptions: {
paths: [
'bower_components/semantic-ui'
]
}
});
return app.toTree();
};
I can't even create a new ember project in a new directory now to validate this because I keep getting the following error:
EPERM, rename 'C:\Users\me\AppData\Roaming\npm-cache\debug\2.2.0\package\package.json'
Error: EPERM, rename 'C:\Users\me\AppData\Roaming\npm-cache\debug\2.2.0\package\package.json'
at Error (native)

Categories

Resources