Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes main thread of Electron App in prod version of app #1198

Closed
darylcober opened this issue Sep 30, 2021 · 3 comments
Closed

Crashes main thread of Electron App in prod version of app #1198

darylcober opened this issue Sep 30, 2021 · 3 comments

Comments

@darylcober
Copy link

darylcober commented Sep 30, 2021

Describe the bug
When included in an Electron Build this lib crashes the main thread when app is launched with the following error:
[2021-09-29 22:59:43.642] [error] TypeError: Cannot read property 'url' of undefined
at Object. (C:\Users\xxxr\AppData\Local\Programs\xxx\resources\app.asar\node_modules\kafkajs\src\errors.js:198:31)
at Module._compile (internal/modules/cjs/loader.js:1078:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
at Module.load (internal/modules/cjs/loader.js:935:32)
at Module._load (internal/modules/cjs/loader.js:776:14)
at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
at Module.require (internal/modules/cjs/loader.js:959:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (C:\Users\xxx\AppData\Local\Programs\xxx\resources\app.asar\node_modules\kafkajs\src\instrumentation\emitter.js:3:26)
at Module._compile (internal/modules/cjs/loader.js:1078:30)

To Reproduce
Include kafkajs in dependencies of Electron App and build with Electron-Builder

The bug is in kafkajs/src/errors.js at line 198 - const issueUrl = pkgJson.bugs.url

When pkgJson is inspected the following is observed:
[2021-09-29 22:55:25.692] [info] kafka package => {
author: { name: 'Tulio Ornelas', email: '' },
dependencies: {},
description: 'A modern Apache Kafka client for node.js',
devDependencies: {
'@types/node': '^12.0.8',
'@typescript-eslint/typescript-estree': '^1.10.2',
eslint: '^6.8.0',
'eslint-config-prettier': '^6.0.0',
'eslint-config-standard': '^13.0.1',
'eslint-plugin-import': '^2.18.2',
'eslint-plugin-node': '^11.0.0',
'eslint-plugin-prettier': '^3.1.0',
'eslint-plugin-promise': '^4.2.1',
'eslint-plugin-standard': '^4.0.0',
execa: '^2.0.3',
glob: '^7.1.4',
husky: '^3.0.1',
ip: '^1.1.5',
jest: '^25.1.0',
'jest-circus': '^25.1.0',
'jest-extended': '^0.11.2',
'jest-junit': '^10.0.0',
jsonwebtoken: '^8.5.1',
'lint-staged': '^9.2.0',
mockdate: '^2.0.5',
prettier: '^1.18.2',
semver: '^6.2.0',
typescript: '^3.8.3',
uuid: '^3.3.2'
},
engines: { node: '>=10.13.0' },
homepage: 'https://kafka.js.org',
license: 'MIT',
'lint-staged': { '*.js': [ 'prettier --write', 'git add' ] },
main: 'index.js',
name: 'kafkajs',
repository: { type: 'git', url: 'git+https://github.com/tulios/kafkajs.git' },
types: 'types/index.d.ts',
version: '1.15.0'
}

The expected bugs node is not included in the presented data.

Expected behavior
The bugs node should be included or exception handling should be introduced to prevent catastrophic failure.

Environment:

  • OS: [WIN10]
  • KafkaJS version [e.g. 1.15.0]
  • NodeJS version [e.g. 14.17.6]
  • electron-builder version=22.11.7 os=10.0.19042

Additional context
It's not cool to have your lib send data outside the app without the users consent!

@tulios
Copy link
Owner

tulios commented Sep 30, 2021

It's not cool to have your lib send data outside the app without the users consent!

Hey @darylcober it's important to validate your assumptions before making such claims, that's the beauty of open source projects. the bugs URL is a static link to GitHub and it is only used in the KafkaJSInvariantViolation error to compose the helpUrl, which is making it simple for users to report issues that should not happen. To be more explicit, we do not send any data outside of the app without the user's consent.

The package.json definition:

kafkajs/package.json

Lines 21 to 23 in e99be62

"bugs": {
"url": "https://github.com/tulios/kafkajs/issues"
},

Where it is used:

kafkajs/src/errors.js

Lines 199 to 212 in 7292734

const issueUrl = bugs ? bugs.url : null
class KafkaJSInvariantViolation extends KafkaJSNonRetriableError {
constructor(e) {
const message = e.message || e
super(`Invariant violated: ${message}. This is likely a bug and should be reported.`)
this.name = 'KafkaJSInvariantViolation'
if (issueUrl !== null) {
const issueTitle = encodeURIComponent(`Invariant violation: ${message}`)
this.helpUrl = `${issueUrl}/new?assignees=&labels=bug&template=bug_report.md&title=${issueTitle}`
}
}
}

With that out of the way, let's look at your issue:

I think some packaging process is removing the bugs section from the package.json, there is a fix already in place (#984), you can try the version 1.16.0-beta.1.

@mpataki
Copy link

mpataki commented Sep 30, 2021

@tulios hi -- I'm also interested in this fix, so I'm glad to hear that it's in your pipeline.

It does appear that this fix was merged nearly 10 months ago. Do you have a sense of when it will be included in a stable release? I'm just a bit weary about bumping to a beta version.

Thanks for your work on this lib man

@Nevon
Copy link
Collaborator

Nevon commented Mar 9, 2022

This was fixed in 1.16.0

@Nevon Nevon closed this as completed Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants