[GH-ISSUE #1409] TypeError is returned when logged in #456

Closed
opened 2026-03-16 15:25:32 +03:00 by kerem · 5 comments
Owner

Originally created by @carlos-ds on GitHub (Jan 3, 2021).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/1409

When logged in (in my case via Google), clicking on "Send request" returns a type error.

TypeError: Cannot read property 'value' of undefined
    at c5959e3.modern.js:1
    at c5959e3.modern.js:1
    at Generator.next (<anonymous>)
    at r (856170b.modern.js:2)
    at l (856170b.modern.js:2)

image

After logging out and making the exact same request, the response is what I expected.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
Originally created by @carlos-ds on GitHub (Jan 3, 2021). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/1409 When logged in (in my case via Google), clicking on "Send request" returns a type error. ``` TypeError: Cannot read property 'value' of undefined at c5959e3.modern.js:1 at c5959e3.modern.js:1 at Generator.next (<anonymous>) at r (856170b.modern.js:2) at l (856170b.modern.js:2) ``` ![image](https://user-images.githubusercontent.com/20499950/103485666-59dfcf00-4df8-11eb-97e0-8970c7042a50.png) After logging out and making the exact same request, the response is what I expected. **Desktop (please complete the following information):** - OS: Windows 10 - Browser: Chrome
kerem 2026-03-16 15:25:32 +03:00
Author
Owner

@carlos-ds commented on GitHub (Jan 3, 2021):

This seems to be pointing at the if (fb.currentSettings[0].value) (and [1], [2]) statements, where it can't access value since currentSettings is undefined. Probably because I don't have any settings yet? I'm not familiar with the Firebase internals.

As an example from collection.vue on line 134:

syncCollections() {
      if (fb.currentUser !== null) {
        if (fb.currentSettings[0].value) {
          fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
        }
      }
    }

I suspect it would be best to change it to:

syncCollections() {
      if (fb.currentUser !== null && fb.currentSettings[0]) {
        if (fb.currentSettings[0].value) {
          fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
        }
      }
    },

I have tested this locally and it seems to fix the problem.

** On second thought, abstracting the if-statements into a separate function and then using that in the writeHistory, writeEnvironments and writeCollections helper functions seems like the cleanest option. But perhaps I'm missing something here? If not, then I'd like to open a pull request for this.

<!-- gh-comment-id:753659440 --> @carlos-ds commented on GitHub (Jan 3, 2021): This seems to be pointing at the `if (fb.currentSettings[0].value)` (and [1], [2]) statements, where it can't access `value` since `currentSettings` is undefined. Probably because I don't have any settings yet? I'm not familiar with the Firebase internals. As an example from collection.vue on line 134: ``` syncCollections() { if (fb.currentUser !== null) { if (fb.currentSettings[0].value) { fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections))) } } } ``` I suspect it would be best to change it to: ``` syncCollections() { if (fb.currentUser !== null && fb.currentSettings[0]) { if (fb.currentSettings[0].value) { fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections))) } } }, ``` I have tested this locally and it seems to fix the problem. ** On second thought, abstracting the if-statements into a separate function and then using that in the `writeHistory`, `writeEnvironments` and `writeCollections` helper functions seems like the cleanest option. But perhaps I'm missing something here? If not, then I'd like to open a pull request for this.
Author
Owner

@AndrewBastin commented on GitHub (Jan 3, 2021):

I can't find a way to replicate this. Is it happening everytime after you login ?

<!-- gh-comment-id:753683250 --> @AndrewBastin commented on GitHub (Jan 3, 2021): I can't find a way to replicate this. Is it happening everytime after you login ?
Author
Owner

@liyasthomas commented on GitHub (Jan 4, 2021):

@carlos-ds this is exactly due to your Settings being empty. This happened when you don't turn on sync in settings. I liked your suggestion on abstracting if statements of helper functions feel free to open a PR — meanwhile I'll just fix this by checking existence of Settings key as you mentioned in the example.

<!-- gh-comment-id:753701336 --> @liyasthomas commented on GitHub (Jan 4, 2021): @carlos-ds this is exactly due to your Settings being empty. This happened when you don't turn on sync in settings. I liked your suggestion on abstracting if statements of helper functions feel free to open a PR — meanwhile I'll just fix this by checking existence of Settings key as you mentioned in the example.
Author
Owner

@liyasthomas commented on GitHub (Jan 4, 2021):

@carlos-ds let me know if this issue still persist. Do a force refresh before testing.

<!-- gh-comment-id:753709614 --> @liyasthomas commented on GitHub (Jan 4, 2021): @carlos-ds let me know if this issue still persist. Do a force refresh before testing.
Author
Owner

@carlos-ds commented on GitHub (Jan 4, 2021):

@liyasthomas yes, this seems to be fixed now. I'll have a look at abstracting the if-statements next week.

<!-- gh-comment-id:753769028 --> @carlos-ds commented on GitHub (Jan 4, 2021): @liyasthomas yes, this seems to be fixed now. I'll have a look at abstracting the if-statements next week.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#456
No description provided.