segmentio / segmentio/analytics.js-integrations
Promise.prototype.finally not defined in MS Edge due to replacement in @segment/tracktor module
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 125
- Forks
- 136
- Avg merge
- 2h 45m
- Merged PRs (30d)
- 1
Description
Something in the @segment/tracktor module has a dependency on an old version of core-js where Promise.prototype.finally is not defined. In Microsoft Edge, the native Promise object gets replaced by the core-js version which can cause things to break if code depends on using finally
This is a related issue where the core-js author references the fact that v2 or less does not implement Promise#finally in its polyfill (see: https://github.com/zloirock/core-js/blob/v2/modules/es6.promise.js)
To reproduce, in the @segment/tracktor project, in the build/index.html file, replace the line <script type="text/javascript" src="tracktor.js"></script> with:
<script>
console.log('running native Promise#finally')
Promise.resolve(true).finally(() =>
console.log('Promise#finally executed')
)
</script>
<script type="text/javascript" src="tracktor.js"></script>
<script>
document
.getElementById('dynamic-btn')
.addEventListener('click', function () {
console.log('button clicked')
console.log('Promise#finally no longer here')
console.log(Promise.prototype.finally)
Promise.resolve(true).finally(() => console.log('this will not run'))
})
</script>
and run on Edge.

What I'm guessing is happening is:
@babel/preset-env@7.4.5depends oncore-js-compat@3.1.1core-js-compattells@babel/preset-envto include things fromcore-js@babel/preset-envfinds an includedcore-jsinstalled
a.wait-on@3.3.0depends oncore-js@2.6.5
b.jest-dev-server@4.3.0depends onwait-on@3.3.0@babel/preset-envinjects thecore-js@2.6.5polyfills it determines are needed based on the defined targets and built ins
@babel/preset-env emits a warning about this here: https://github.com/babel/babel/blob/c5ba345ac26d90fb5da8954f00f5c7285ee5ada8/packages/babel-preset-env/src/normalize-options.js#L220
I think this can be alleviated by explicitly defining a dependency on core-js@^3.6.5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in the @segment/tracktor project using build/index.html and Microsoft Edge, then inspect the dependency chain involving @babel/preset-env, core-js-compat, wait-on, and jest-dev-server. Done means loading tracktor.js no longer removes Promise.prototype.finally and the provided click-handler reproduction succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100