jsnlog.js icon indicating copy to clipboard operation
jsnlog.js copied to clipboard

JSNLog Not resetting xhr object in React native

Open msreddy09 opened this issue 5 years ago • 5 comments

I have written code as below in react native. But I am seeing only one message(very first message) in the server.

Any consecutive requesting fails with [Error: Cannot open, already sending]

import {JL} from 'jsnlog'

 var app = JL.createAjaxAppender("appender").setOptions({     
     'url': 'http://127.0.0.1:8080/log'
 });

 JL().setOptions({
     "appenders": [app]
 });


class App extends React.Component {
    componentDidMount () {
      JL().info('Application started')
      JL()..debug('Application started with no config')
    }
    render() {
        return(
            <div className ="container-fluid">
               <Header />
               <Switch>
                    <Route exact path ="/" component ={HomePage} />
                    <Route  path ="/about" component ={AboutPage} />
                    <Route  path ="/courses" component ={CoursesPage} />
                    <Route  component={PageNotFound} />
               </Switch>
              
            </div>
        )
    }
}

export default App;

Temporarily, we tried re-initialized XHR object inside the

  AjaxAppender.prototype.sendLogItemsAjax = function (logItems, successCallback) {

        this.xhr = JL._createXMLHttpRequest()
    // rest of the code
}```

msreddy09 avatar Feb 06 '20 02:02 msreddy09

I encountered the same issue on a react-native app. will there be a fix for this?

bogdandoi avatar Oct 06 '20 08:10 bogdandoi

I am not familiar with React Native, so not really in a position to investigate this. But if you could send me a pull request with a fix, that would be great.

mperdeck avatar Oct 06 '20 12:10 mperdeck

I've created a feature branch with the fix but I'm not authorized to push it. @mperdeck can you give me access for this?

bogdanicis avatar Oct 15 '20 13:10 bogdanicis

Did you try to push to my repo directly, or create a pull request?

Creating a pull request would be the way to go. To do that, you'd first create a fork, make your updates on the fork, then create the pull request to get the changes into my repo.

See https://guides.github.com/activities/forking/

mperdeck avatar Oct 18 '20 04:10 mperdeck

I created the PR: https://github.com/mperdeck/jsnlog.js/pull/77. @mperdeck , please take a look when you have the time

bogdanicis avatar Oct 26 '20 14:10 bogdanicis