atom / telemetry

sends usage metrics to GitHub's internal analytics pipeline
MIT License
11 stars 12 forks source link

Telemetry stack when using isomorphic-fetch #15

Closed smashwilson closed 6 years ago

smashwilson commented 6 years ago

👋 Hey!

I'm getting the following telemetry stack from Atom when attempting to authenticate with the GitHub package:

Error reporting opt in Error: native promise missing, set Fetch.Promise to your favorite alternative
    at new Fetch (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/node-fetch/index.js:74:15)
    at Fetch (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/node-fetch/index.js:70:16)
    at module.exports (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/isomorphic-fetch/fetch-npm-node.js:8:25)
    at StatsStore.fetch (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/telemetry-github/out/index.js:179:22)
    at StatsStore.post (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/telemetry-github/out/index.js:172:27)
    at StatsStore.sendOptInStatusPing (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/telemetry-github/out/index.js:93:47)
    at new StatsStore (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/telemetry-github/out/index.js:46:28)
    at Function.getStore (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/reporter.js:142:21)
    at Function.addCustomEvent (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/reporter.js:60:16)
    at Function.sendEvent (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/reporter.js:78:16)
    at Object.begin (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/metrics.js:55:41)
    at ensureClientId (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/metrics.js:28:42)
    at Object.ensureClientId (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/metrics.js:101:13)
    at Object.activate (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/node_modules/metrics/lib/metrics.js:28:16)
    at Package.activateNow (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package.js:230:33)
    at measure (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package.js:206:33)
    at Package.measure (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package.js:88:25)
    at activationPromise.Promise (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package.js:200:20)
    at new Promise (<anonymous>)
    at Package.activate (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package.js:198:38)
    at PackageManager.activatePackage (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package-manager.js:695:42)
    at config.transactAsync (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package-manager.js:670:36)
    at Config.transactAsync (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/config.js:866:28)
    at PackageManager.activatePackages (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package-manager.js:668:23)
    at PackageManager.activate (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/package-manager.js:647:50)
    at loadStatePromise.loadState.then (/Users/smashwilson/src/atom/atom/out/Atom.app/Contents/Resources/app/src/atom-environment.js:871:27)
    at <anonymous>

It looks like more snapshot pain; because the Promise global isn't available while the snapshot is being generated, node-fetch isn't seeing it.

I'm not sure what the best way to work around this one is - exclude isomorphic-fetch from the snapshot, maybe?

smashwilson commented 6 years ago

Oh - I looked at the GitHub package to see why we weren't having the same problem, because we're using fetch for network operations, too, and we're just using the built-in one from Chromium.

annthurium commented 6 years ago

thanks for reporting, @smashwilson !

I merged some changes to telemetry to hopefully address this problem but I'm going to keep this open until I've published and verified the fix works with Atom.