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

TypeError: privateMap.get is not a function #301

Closed
mertyildiran opened this issue May 22, 2023 · 7 comments
Closed

TypeError: privateMap.get is not a function #301

mertyildiran opened this issue May 22, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@mertyildiran
Copy link

mertyildiran commented May 22, 2023

Screenshot from 2023-05-22 06-06-47

privateMap.get is not a function
TypeError: privateMap.get is not a function
    at __classPrivateFieldGet (http://localhost:3000/static/js/bundle.js:181799:21)
    at new Lt (http://localhost:3000/static/js/vendors-node_modules_descope_web-component_dist_esm_index_js.chunk.js:278:78)
    at new Mt (http://localhost:3000/static/js/vendors-node_modules_descope_web-component_dist_esm_index_js.chunk.js:592:5)
    at createElement (http://localhost:3000/static/js/bundle.js:97103:38)
    at createInstance (http://localhost:3000/static/js/bundle.js:98290:24)
    at completeWork (http://localhost:3000/static/js/bundle.js:107416:32)
    at completeUnitOfWork (http://localhost:3000/static/js/bundle.js:110721:20)
    at performUnitOfWork (http://localhost:3000/static/js/bundle.js:110693:9)
    at workLoopSync (http://localhost:3000/static/js/bundle.js:110619:9)
    at renderRootSync (http://localhost:3000/static/js/bundle.js:110585:11)

@descope/react-sdk version: 1.0.4

Error happens even running locally.

@asafshen
Copy link
Member

@mertyildiran thanks for reporting!

In reference to our previous discussion regarding the recent issue,

I have not yet been able to reproduce this error. Could you please confirm whether this issue originates specifically from the Descope SDK code?

few questions:

  1. Do you have a way to run the application with a sourcemap, so we can see the exception call-stack with proper names/files?
  2. Does the error happen when the code is running both locally and served from a docker container?
  3. I have created a simple application that runs a simple react application with descope inside a docker container (fyi it is running against mine Descope project). can you see if that reproduce there when you run it? can you change the code/create a simple open source example where this reproduces?
    (instruction in the readme file, you can run the project locally or inside a docker iamge)

@mertyildiran
Copy link
Author

@mertyildiran thanks for reporting!

In reference to our previous discussion regarding the recent issue,

I have not yet been able to reproduce this error. Could you please confirm whether this issue originates specifically from the Descope SDK code?

few questions:

  1. Do you have a way to run the application with a sourcemap, so we can see the exception call-stack with proper names/files?
  2. Does the error happen when the code is running both locally and served from a docker container?
  3. I have created a simple application that runs a simple react application with descope inside a docker container (fyi it is running against mine Descope project). can you see if that reproduce there when you run it? can you change the code/create a simple open source example where this reproduces?
    (instruction in the readme file, you can run the project locally or inside a docker iamge)

I have opened the reproducing PR: asafshen/descope-react-in-docker#1

@mertyildiran
Copy link
Author

mertyildiran commented May 22, 2023

Looking at the unminified compiled JavaScript code:

import { __awaiter as t, __classPrivateFieldGet as e, __classPrivateFieldSet as i } from "tslib";
...
class Lt extends HTMLElement {
    constructor(o) {
        super(),
            B.add(this),
            G.set(this, !1),
            J.set(this, new F()),
            Q.set(this, new F()),
            (this.nextRequestStatus = new F({ isLoading: !1 })),
            X.set(this, void 0),
            Y.set(this, { popstate: e(this, B, "m", nt).bind(this) }),
            Z.set(this, void 0),
            lt.set(
                this,
                W(() =>
                    t(this, void 0, void 0, function* () {
                        const t = O(this.projectId, "config.json");
                        try {
                            const { body: e, headers: i } = yield E(t, "json");
                            return { projectConfig: e, executionContext: { geo: i["x-geo"] } };
                        } catch (t) {
                            this.logger.error("Cannot get config file", "make sure that your projectId & flowId are correct");
                        }
                        return {};
                    })
                )
            ),
            (this.logger = {
                error: (t, i = "") => {
                    console.error(t, i, new Error()), e(this, B, "m", vt).call(this, t, i);
                },
                info: (t, e = "") => {
                    console.log(t, e);
                },
            }),
            i(this, Z, o, "f"),
            e(this, B, "m", tt).call(this);
    }

Since the error is thrown while creating a new instance of Lt class and that class is actually BaseDescopeWc class, it should be a problem in the constructor method of BaseDescopeWc. The __classPrivateFieldGet (calls to e alias) suggests that there is a problem while trying to access a private property of class BaseDescopeWc. Therefore the error should be thrown in these lines.

@asafshen
Copy link
Member

@mertyildiran, thank you for providing detailed information and for the reproduction PR. 🚀

I will proceed with checking it

@asafshen
Copy link
Member

asafshen commented May 24, 2023

@mertyildiran we have found the root cause of the issue

our internal packages are missing tslib dependency

We are working on a fix, but in the meantime, you can add the latest tslib as a dependency - and run the project again

npm install --save tslib

npm run start

I have added a PR to the sample repo to demonstrate the temporary solution

asafshen added a commit to descope/descope-js that referenced this issue May 24, 2023
## Related Issues
descope/react-sdk#301

## Description
Add tslib dep
@asafshen
Copy link
Member

The issue is now fixed and avaialble in the latest next version (0.0.0-next-ad987b29-20230525)

an GA version will be avaialble soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants