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

Sync failed: please check your network connection. #46

Closed
CatTail opened this issue Feb 3, 2017 · 12 comments
Closed

Sync failed: please check your network connection. #46

CatTail opened this issue Feb 3, 2017 · 12 comments
Labels

Comments

@CatTail
Copy link

CatTail commented Feb 3, 2017

I use Version 1.0.0-beta.3 (1.0.0-beta.3), and CAN connect to Github gist, but this message keep coming, DevTool console told me

Unhandled rejection TypeError: Cannot convert undefined or null to object
    at NavigationPanel.renderLangTags (file:///Applications/Lepton.app/Contents/Resources/app.asar/bundle/app.bundle.js:1962:14)
    at NavigationPanel.renderTagSection (file:///Applications/Lepton.app/Contents/Resources/app.asar/bundle/app.bundle.js:2019:16)
    at NavigationPanel.render (file:///Applications/Lepton.app/Contents/Resources/app.asar/bundle/app.bundle.js:2052:14)
    at /Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:796:21
    at measureLifeCyclePerf (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:75:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:795:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:822:32)
    at ReactCompositeComponentWrapper.performInitialMount (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:362:30)
    at ReactCompositeComponentWrapper.mountComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:258:21)
    at Object.mountComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactReconciler.js:46:35)
    at ReactCompositeComponentWrapper.performInitialMount (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:371:34)
    at ReactCompositeComponentWrapper.mountComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:258:21)
    at Object.mountComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactReconciler.js:46:35)
    at Object.updateChildren (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactChildReconciler.js:121:51)
    at ReactDOMComponent._reconcilerUpdateChildren (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactMultiChild.js:208:32)
    at ReactDOMComponent._updateChildren (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactMultiChild.js:312:31)
    at ReactDOMComponent.updateChildren (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactMultiChild.js:299:12)
    at ReactDOMComponent._updateDOMChildren (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactDOMComponent.js:936:12)
    at ReactDOMComponent.updateComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactDOMComponent.js:754:10)
    at ReactDOMComponent.receiveComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactDOMComponent.js:716:10)
    at Object.receiveComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactReconciler.js:125:22)
    at ReactCompositeComponentWrapper._updateRenderedComponent (/Applications/Lepton.app/Contents/Resources/app.asar/node_modules/react-dom/lib/ReactCompositeComponent.js:754:23)
@aaronice
Copy link

aaronice commented Feb 3, 2017

Same issue with Version 1.0.0-beta.3 on Mac OS X.

image

The issue occurs during login, and Lepton hangs in the loading phase.

image

@hackjutsu hackjutsu added the bug label Feb 3, 2017
@hackjutsu
Copy link
Owner

hackjutsu commented Feb 3, 2017

@CatTail @aaronice Can you paste the log in ~/Library/Application Support/Lepton/logs?

The Object.keys(gistTags) is the culprit which fails to read keys from null.

  renderLangTags () {
    let gistTags = this.props.gistTags
    let activeGistTag = this.props.activeGistTag
    let langTagList = []

    Object.keys(gistTags)
    .filter(tag => {
      return tag.startsWith('lang@')
    })
    .sort()
    .forEach(prefixedLang => {
      langTagList.push(
        <div key={ prefixedLang }>
          <a className={ prefixedLang === activeGistTag ? 'active-gist-tag' : 'gist-tag' }
            onClick={ this.handleClicked.bind(this, prefixedLang) }>
            { '#' + Resolved(prefixedLang) }
          </a>
        </div>
      )
    })

    return langTagList
  } // renderLangTags()

It looks like the code complains about the initial value of a redux state gistTags, which is set to null.

export default function (state = null, action) {
  switch (action.type) {
    case UPDATE_GIST_TAGS:
      return action.payload
    case LOGOUT_USER_SESSION:
      return null
    default:
  }
  return state
}

https://github.com/hackjutsu/Lepton/blob/master/app/reducers/reducer_gist_tags.js

This might be fixed by simply replacing the initial value from null to {}. But a more tricky question is why the state doesn't get updated. I hope it's just a race condition.

@CatTail
Copy link
Author

CatTail commented Feb 4, 2017

@hackjutsu log result are

2017-02-03T23:04:05.834Z - info: Found user profile null
2017-02-03T23:04:07.370Z - info: [Dispatch] updateAuthWindowStatus ON
2017-02-03T23:04:32.228Z - info: [Dispatch] updateAuthWindowStatus OFF
2017-02-03T23:04:32.232Z - info: [Dispatch] updateUserSession IN_PROGRESS
2017-02-03T23:04:34.307Z - info: [Dispatch] updateUserSession IN_PROGRESS
2017-02-03T23:04:34.309Z - info: [Dispatch] updateAccessToken
2017-02-03T23:04:38.087Z - debug: The gist number on this page is 30
2017-02-03T23:04:40.033Z - debug: The gist number on this page is 30
2017-02-03T23:04:41.778Z - debug: The gist number on this page is 30
2017-02-03T23:04:42.862Z - debug: The gist number on this page is 3
2017-02-03T23:04:44.013Z - debug: The gist number on this page is 0
2017-02-03T23:04:44.022Z - error: The request has failed: TypeError: Cannot read property 'match' of null
2017-02-03T23:04:44.023Z - info: [Dispatch] updateUserSession ACTIVE
2017-02-03T23:04:59.345Z - info: Found user profile null
2017-02-03T23:05:00.771Z - info: [Dispatch] updateAuthWindowStatus ON
2017-02-03T23:05:25.349Z - info: [Dispatch] updateAuthWindowStatus OFF
2017-02-03T23:05:25.355Z - info: [Dispatch] updateUserSession IN_PROGRESS
2017-02-03T23:05:27.031Z - info: [Dispatch] updateUserSession IN_PROGRESS
2017-02-03T23:05:27.034Z - info: [Dispatch] updateAccessToken
2017-02-03T23:05:30.536Z - debug: The gist number on this page is 30
2017-02-03T23:05:32.357Z - debug: The gist number on this page is 30
2017-02-03T23:05:34.396Z - debug: The gist number on this page is 30
2017-02-03T23:05:35.626Z - debug: The gist number on this page is 3
2017-02-03T23:05:36.889Z - debug: The gist number on this page is 0
2017-02-03T23:05:36.901Z - error: The request has failed: TypeError: Cannot read property 'match' of null
2017-02-03T23:05:36.902Z - info: [Dispatch] updateUserSession ACTIVE
2017-02-04T00:53:13.418Z - info: The app window is closed

@hackjutsu
Copy link
Owner

@CatTail Got it. This is caused by a null value when parsing the description.

export function descriptionParser (rawDescription = 'AWESOME GIST') {
  const regexForTitle = rawDescription.match(/\[.*\]/)
  const rawTitle = regexForTitle && regexForTitle[0] || ''
  const title = (rawTitle.length > 0) && rawTitle.substring(1, regexForTitle[0].length - 1) || ''

  const regextForCustomTags = rawDescription.match(/#tags:.*$/)
  const customTags = regextForCustomTags && regextForCustomTags[0] || ''

  const description = rawDescription.substring(rawTitle.length, rawDescription.length - customTags.length)

  return { title, description, customTags }
}

I thought the es6 initial value in the argument list will handle the case when the arg is null. But it turns out it only works when there is no args or the arg is undefined.

Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed. ref

Good lesson learned. I'll fix it soon

@hackjutsu
Copy link
Owner

hackjutsu commented Feb 4, 2017

Should be fixed:6af171e

Please have a test: https://github.com/hackjutsu/Lepton/releases/tag/v1.0.0-beta.4

@ustrugany
Copy link

Issue still is happening to me on version 1.5.0 on macos, unable to login and use app.

@hansjons
Copy link

Hi I'm on 1.5.0 on macos 10.13.2 and am getting the "Sync failed message". The dev console does not show any message at all. Lepton was working ok until I added some gists with a [title] and tags # then I was logged out and am now getting the sync message. I tried changing the gists directly on github but Lepton is still in a limbo.

@hackjutsu
Copy link
Owner

@hansjons Try delete ~/Library/Application Support/Lepton/ in v1.5.0, or try the alpha release for 1.5.1.
https://github.com/hackjutsu/Lepton/releases/tag/v1.5.1-alpha

@hansjons
Copy link

@hackjutsu I tried both and can confirm that both methods worked for me. Cool app by the way and thanks for the prompt reply:-)

@TimeBandit
Copy link

TimeBandit commented Oct 2, 2018

I'm seeing this issue on Ubuntu 18.04.1 LTS on my desktop.
Still work on 16.0.4 LTS on my laptop.
The upgrade to the latest LTS version of Ubuntu on my desktop somehow broke Lepton
Let me know if I should open a new ticket

@vamsden
Copy link

vamsden commented Oct 24, 2018

Can confirm same issue still persist in Ubuntu 18.04 LTS

@TimeBandit
Copy link

TimeBandit commented Oct 24, 2018

@vamsden a dedicated issue was raised here 👉 #320

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

No branches or pull requests

7 participants