koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
172 stars 43 forks source link

On Demand - cannot read properties of null / childprocess.spawnsync EONENT Error #153

Closed yshwartzou closed 2 years ago

yshwartzou commented 2 years ago

I have been getting an error when trying to query sp-rest-proxy in an On Demand configuration I created a simple node.js package to isolate the the issue. Please see the pakcage.json below the error.

When I traced the error the issue appears to be that childproces.spansysnc is getting an EONENT error when tying to create the span of electron.

Node Version: 16.15.1 Operating System: Windows 10 Error Recieved:

GET: https://www.sharepoint.com/sites/mysite/
Error TypeError: Cannot read properties of null (reading 'toString')
    at OnDemand.saveAuthData (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:83:44)
    at OnDemand.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\auth\resolvers\OnDemand\OnDemand.js:38:28)
    at Object.getAuth (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\node_modules\node-sp-auth\lib\src\index.js:16:76)
    at SPClient.<anonymous> (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:69:51)
    at step (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:44:23)
    at Object.next (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:25:53)
    at c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:15:12)
    at SPClient.fetch (C:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\client.js:65:20) {stack: 'TypeError: Cannot read properties of null (re…les\sp-rest-proxy\dist\utils\client.js:65:20)', message: 'Cannot read properties of null (reading 'toString')'}
arg1: TypeError: Cannot read properties of null (reading 'toString')\n    at OnDemand.saveAuthData (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:83:44)\n    at OnDemand.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\auth\\resolvers\\OnDemand\\OnDemand.js:38:28)\n    at Object.getAuth (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\node_modules\\node-sp-auth\\lib\\src\\index.js:16:76)\n    at SPClient.<anonymous> (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:69:51)\n    at step (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:44:23)\n    at Object.next (C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:25:53)\n    at C:\\Users\\userName\\NodeProjects\\spo-proxy\\node_modules\\sp-rest-proxy\\dist\\utils\\client.js:19… …
Logger.error @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\utils\logger.js:51:25
<anonymous> @ c:\Users\userName\NodeProjects\spo-proxy\node_modules\sp-rest-proxy\dist\core\BasicRouter.js:118:34
processTicksAndRejections @ internal/process/task_queues:96:5
{
  "name": "spo-proxy",
  "version": "1.0.0",
  "description": "Proxy to SharePoint online",
  "main": "index.js",
  "scripts": {
    "proxy": "node ./index.js"
  },
  "author": "user",
  "license": "ISC",
  "dependencies": {
    "sp-rest-proxy": "^3.3.5"
  },
  "devDependencies": {
    "electron": "^20.1.3"
  }
}
koltyakov commented 2 years ago

Please post the issue to https://github.com/s-KaiNet/node-sp-auth - the library which does auth layer.

Another option is to try downgrading Electron (last version I successfully tried was 11.4.0, yet on macOS) as they are changing the way how to get cookies with each version.

yshwartzou commented 2 years ago

@koltyakov , Thank you. I will post the issue there. I wanted to share here that I figured out how to get around it temporarily by referring to the absolute path of the electron exe in the private.json file as follows.

{
  "siteUrl": "https://www.sharepoint.com/sites/mySite/",
  "strategy": "OnDemandCredentials",
  "ondemand": true,
  "force": true,
  "electron": "C:\\Users\\user\\NodeProjects\\my-project\\node_modules\\electron\\dist\\electron.exe"
}