{"action":"created","issue":{"url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/4370","repository_url":"https://api.github.com/repos/jupyterlab/jupyterlab","labels_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/4370/labels{/name}","comments_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/4370/comments","events_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/4370/events","html_url":"https://github.com/jupyterlab/jupyterlab/issues/4370","id":313672351,"node_id":"MDU6SXNzdWUzMTM2NzIzNTE=","number":4370,"title":"Cannot read property 'cache' of undefined","user":{"login":"mpa74","id":10248117,"node_id":"MDQ6VXNlcjEwMjQ4MTE3","avatar_url":"https://avatars2.githubusercontent.com/u/10248117?v=4","gravatar_id":"","url":"https://api.github.com/users/mpa74","html_url":"https://github.com/mpa74","followers_url":"https://api.github.com/users/mpa74/followers","following_url":"https://api.github.com/users/mpa74/following{/other_user}","gists_url":"https://api.github.com/users/mpa74/gists{/gist_id}","starred_url":"https://api.github.com/users/mpa74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpa74/subscriptions","organizations_url":"https://api.github.com/users/mpa74/orgs","repos_url":"https://api.github.com/users/mpa74/repos","events_url":"https://api.github.com/users/mpa74/events{/privacy}","received_events_url":"https://api.github.com/users/mpa74/received_events","type":"User","site_admin":false},"labels":[{"id":567631788,"node_id":"MDU6TGFiZWw1Njc2MzE3ODg=","url":"https://api.github.com/repos/jupyterlab/jupyterlab/labels/pkg:services","name":"pkg:services","color":"1d76db","default":false},{"id":387307886,"node_id":"MDU6TGFiZWwzODczMDc4ODY=","url":"https://api.github.com/repos/jupyterlab/jupyterlab/labels/type:Question","name":"type:Question","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/jupyterlab/jupyterlab/milestones/6","html_url":"https://github.com/jupyterlab/jupyterlab/milestone/6","labels_url":"https://api.github.com/repos/jupyterlab/jupyterlab/milestones/6/labels","id":1961957,"node_id":"MDk6TWlsZXN0b25lMTk2MTk1Nw==","number":6,"title":"Future","description":"The future milestone is for issues that we may implement in the future. This includes issue that:\r\n\r\n- We have not committed to implementing the feature.\r\n- We have committed to implementing the feature, but have not decided in which milestone the feature will be implemented.\r\n\r\n","creator":{"login":"ellisonbg","id":27600,"node_id":"MDQ6VXNlcjI3NjAw","avatar_url":"https://avatars3.githubusercontent.com/u/27600?v=4","gravatar_id":"","url":"https://api.github.com/users/ellisonbg","html_url":"https://github.com/ellisonbg","followers_url":"https://api.github.com/users/ellisonbg/followers","following_url":"https://api.github.com/users/ellisonbg/following{/other_user}","gists_url":"https://api.github.com/users/ellisonbg/gists{/gist_id}","starred_url":"https://api.github.com/users/ellisonbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ellisonbg/subscriptions","organizations_url":"https://api.github.com/users/ellisonbg/orgs","repos_url":"https://api.github.com/users/ellisonbg/repos","events_url":"https://api.github.com/users/ellisonbg/events{/privacy}","received_events_url":"https://api.github.com/users/ellisonbg/received_events","type":"User","site_admin":false},"open_issues":601,"closed_issues":71,"state":"open","created_at":"2016-08-25T00:42:23Z","updated_at":"2018-12-14T17:47:15Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-04-12T10:44:19Z","updated_at":"2018-12-15T22:18:57Z","closed_at":null,"author_association":"NONE","body":"I want to use @jupyterlab/services in my react application for messaging with Jupyter notebooks. \r\nBut code from standard examples (i`m only add var options...) did not work. \r\n\r\n**ERROR** TypeError: Cannot read property 'cache' of undefined\r\nnode_modules/@jupyterlab/services/lib/serverconnection.js:179\r\n  176 | }\r\n  177 | // Use explicit cache buster when `no-store` is set since\r\n  178 | // not all browsers use it properly.\r\n 179 | var cache = init.cache || settings.init.cache; **<<---- ERROR**\r\n...\r\n  182 |     url += ((/\\?/).test(url) ? '&' : '?') + (new Date()).getTime();\r\n\r\n**CODE:**\r\n```\r\nimport {\r\n  Kernel\r\n} from '@jupyterlab/services';\r\n\r\nvar options = {\r\n    baseUrl: 'http://localhost:8888',\r\n    wsUrl: 'ws://localhost:8888',    \r\n}\r\nKernel.getSpecs().then(kernelSpecs => {\r\n  return Kernel.startNew({\r\n    name: kernelSpecs.default,\r\n  });\r\n}).then(kernel => {\r\n  let comm = kernel.connectToComm('test');\r\n  comm.open('initial state');\r\n  comm.send('test');\r\n  comm.close('bye');\r\n});\r\n \r\n// Create a comm from the client side.\r\nKernel.getSpecs().then(kernelSpecs => {\r\n  return Kernel.startNew({\r\n    name: kernelSpecs.default,\r\n  });\r\n}).then(kernel => {\r\n  kernel.registerCommTarget('test2', (comm, commMsg) => {\r\n    if (commMsg.content.target_name !== 'test2') {\r\n       return;\r\n    }\r\n    comm.onMsg = (msg) => {\r\n      console.log(msg);  // 'hello'\r\n    };\r\n    comm.onClose = (msg) => {\r\n      console.log(msg);  // 'bye'\r\n    };\r\n  });\r\n \r\n  let code = [\r\n    'from ipykernel.comm import Comm',\r\n    'comm = Comm(target_name=\"test2\")',\r\n    'comm.send(data=\"hello\")',\r\n    'comm.close(data=\"bye\")'\r\n  ].join('\\n');\r\n  kernel.requestExecute({ code: code });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/comments/447601821","html_url":"https://github.com/jupyterlab/jupyterlab/issues/4370#issuecomment-447601821","issue_url":"https://api.github.com/repos/jupyterlab/jupyterlab/issues/4370","id":447601821,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NzYwMTgyMQ==","user":{"login":"Yc-Chen","id":3079912,"node_id":"MDQ6VXNlcjMwNzk5MTI=","avatar_url":"https://avatars2.githubusercontent.com/u/3079912?v=4","gravatar_id":"","url":"https://api.github.com/users/Yc-Chen","html_url":"https://github.com/Yc-Chen","followers_url":"https://api.github.com/users/Yc-Chen/followers","following_url":"https://api.github.com/users/Yc-Chen/following{/other_user}","gists_url":"https://api.github.com/users/Yc-Chen/gists{/gist_id}","starred_url":"https://api.github.com/users/Yc-Chen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yc-Chen/subscriptions","organizations_url":"https://api.github.com/users/Yc-Chen/orgs","repos_url":"https://api.github.com/users/Yc-Chen/repos","events_url":"https://api.github.com/users/Yc-Chen/events{/privacy}","received_events_url":"https://api.github.com/users/Yc-Chen/received_events","type":"User","site_admin":false},"created_at":"2018-12-15T22:18:57Z","updated_at":"2018-12-15T22:18:57Z","author_association":"NONE","body":"I have had the same error. This is how I solved it:\r\n\r\n```\r\nconst settings = ServerConnection.makeSettings({baseUrl: 'http://localhost:8888', wsUrl: 'ws://localhost:8888'})\r\n```\r\n\r\n`makeSettings` will add the other defaults such as 'cache' into 'settings'."}}
{"actor":{"display_login":"Yc-Chen"}}