Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

ReferenceError: realm is not defined #83

Closed
alebsack opened this issue Nov 29, 2018 · 2 comments
Closed

ReferenceError: realm is not defined #83

alebsack opened this issue Nov 29, 2018 · 2 comments

Comments

@alebsack
Copy link

Found this in cloud, v670 (realm-object-server-3.15.0, realm-graphql-service-3.4.0):

error: [http] HTTP response: 688ea707-bfa3-42dd-a671-4a3addd7c194
{"type":"https://realm.io/docs/object-server/problems/invalid-parameters","title":"Your request parameters did not validate.","status":400,"code":601,"invalid_params":[{"name":"path","reason":"path is invalid. It should start with a slash, consist of Latin letters (A-Z, a-z), digits (0-9), dot (.), dash (-), and underscore (_). All components should be non-empty and not start with a dot. The path should not end with .realm, .realm.lock or .realm.management."}]}
/app/node_modules/realm-graphql-service/dist/service.js:119
                this.closeRealm(realm);
                                ^
 ReferenceError: realm is not defined
    at ServerResponse.res.once (/app/node_modules/realm-graphql-service/dist/service.js:119:33)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at ServerResponse.emit (events.js:208:7)
    at onFinish (_http_outgoing.js:720:10)
    at onCorkedFinish (_stream_writable.js:638:5)
    at afterWrite (_stream_writable.js:463:3)
    at _combinedTickCallback (internal/process/next_tick.js:145:20)
    at process._tickCallback (internal/process/next_tick.js:181:9)
@nirinchev
Copy link
Member

@fealebenpae can you make anything of this stacktrace? The callsite in typescript is this one: https://github.com/realm/realm-graphql-service/blob/master/src/service.ts#L290. Is it possible that this gets thrown if the response completes before openRealm resolves on line 294?

@fealebenpae
Copy link
Member

Looking at the transpiled code the problem seems to be that the TypeScript compiler initializes the closure that captures the realm variable before it actually declares the variable. Nikola and I came up with a workaround.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants