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

Mobile Safari - issues with globalThis Polyfill #652

Closed
craigtaub opened this issue May 16, 2019 · 6 comments · Fixed by #653
Closed

Mobile Safari - issues with globalThis Polyfill #652

craigtaub opened this issue May 16, 2019 · 6 comments · Fixed by #653

Comments

@craigtaub
Copy link

craigtaub commented May 16, 2019

We updated to the latest release today (as of today 5.12.4). We immediately started receiving "undefined is not an object (evaluating 'this.globalThis=this')" for anyone using the site on Mobile Safari.
We have reverted to a previous release.

We are using webpack and do not have any other Polyfill for globalThis.

Is there anyone who would be able to look at this?

@craigtaub craigtaub changed the title undefined is not an object (evaluating 'this.globalThis=this') Mobile Safari - issues with globalThis Polyfill May 16, 2019
@davidmarkclements
Copy link
Member

davidmarkclements commented May 16, 2019

this polyfill is here https://github.com/pinojs/pino/blob/master/browser.js#L309-L319

can you try replacing the polyfill with this and seeing if it works?

function polyfillGlobalThis () {
  if (typeof globalThis !== 'undefined') return globalThis
  Object.defineProperty(Object.prototype, 'globalThis', {
    get: function () {
      const g = (this.globalThis = this)
      delete Object.prototype.globalThis
      return g
    },
    configurable: true
  })
  return globalThis
}

@davidmarkclements
Copy link
Member

davidmarkclements commented May 16, 2019

and if that doesn't work can you see if this does:

function polyfillGlobalThis () {

  (function() {
    if (typeof globalThis === 'object') return
    Object.defineProperty(Object.prototype, '__magic__', {
      get: function() {
        return this
      },
      configurable: true
    })
    __magic__.globalThis = __magic__
    delete Object.prototype.__magic__
  }())

  return globalThis

}

@davidmarkclements
Copy link
Member

based on the error they probably won't work - so a fix is in #653

but let me know if they do and we can simplify

@craigtaub
Copy link
Author

Havn't been able to replicate it yet. Really appreciate the quick turnaround.

@davidmarkclements
Copy link
Member

👍 5.12.5 released

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants