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

While running unit tests in backend, connector crashes becuase not interface property #41

Open
mStirner opened this issue Jan 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mStirner
Copy link
Member

[2024.01.25 - 11:20.31.963][warn][system] Backend http://127.0.0.1:8080 not reachable, retry attempt 7...
[2024.01.25 - 11:20.32.891][info][forwarder/mqtt] Connected to ws://127.0.0.1:8080/api/mqtt?x-auth-token=
[2024.01.25 - 11:20.32.893][info][forwarder/mqtt] Client connected to tcp://127.0.0.1:1883
[2024.01.25 - 11:20.32.975][debug][system] WebSocket connected to: ws://127.0.0.1:8080/api/events?x-auth-token=
[2024.01.25 - 11:20.32.975][debug][system] Read to bridge traffic
[2024.01.25 - 11:20.32.975][debug][system] No enabled devices returned, nothing to bridge...
[2024.01.25 - 11:20.36.734][debug][system] Device in backend added {
  _id: '65818918d32dad8dab53e433',
  name: 'SmartMeter',
  interfaces: [
    {
      _id: '6581c55abc21a0a3122b9998',
      type: 'ETHERNET',
      description: 'WebSocket API',
      settings: [Object],
      adapter: [Array]
    }
  ],
  room: '62a4bc8bd9256b5e8d6988a0',
  icon: 'fa-solid fa-gauge-high',
  labels: [ 'test=true', 'protected=false', 'foo=bar' ],
  timestamps: { created: 1706178036728, updated: null },
  enabled: true
}
[2024.01.25 - 11:20.36.736][debug][system] Bridge ws://127.0.0.1:8080/api/devices/65818918d32dad8dab53e433/interfaces/6581c55abc21a0a3122b9998 <-> tcp://192.168.2.155:8080
[2024.01.25 - 11:20.36.853][debug][system] Device in backend updated {
  _id: '65818918d32dad8dab53e433',
  name: 'SaMsUnG FrIdGe',
  interfaces: [
    {
      _id: '6581c55abc21a0a3122b9998',
      type: 'ETHERNET',
      description: 'WebSocket API',
      settings: [Object],
      adapter: [Array]
    }
  ],
  room: '62a4bc8bd9256b5e8d6988a0',
  icon: 'fa-solid fa-gauge-high',
  labels: [ 'test=true', 'protected=true', 'foo=bar' ],
  timestamps: { created: 1706178036728, updated: 1706178036849 },
  enabled: true
}
[2024.01.25 - 11:20.36.854][debug][system] iface 6581c55abc21a0a3122b9998 updated, wait 1.5s
/home/marc/projects/OpenHaus/connector/handler.js:86
                    device.interfaces.forEach((iface) => {
                           ^

TypeError: Cannot read properties of null (reading 'interfaces')
    at WebSocket.<anonymous> (/home/marc/projects/OpenHaus/connector/handler.js:86:28)
    at WebSocket.emit (node:events:513:28)
    at Receiver.receiverOnMessage (/home/marc/projects/OpenHaus/connector/node_modules/ws/lib/websocket.js:1160:20)
    at Receiver.emit (node:events:513:28)
    at Receiver.dataMessage (/home/marc/projects/OpenHaus/connector/node_modules/ws/lib/receiver.js:528:14)
    at Receiver.getData (/home/marc/projects/OpenHaus/connector/node_modules/ws/lib/receiver.js:446:17)
    at Receiver.startLoop (/home/marc/projects/OpenHaus/connector/node_modules/ws/lib/receiver.js:148:22)
    at Receiver._write (/home/marc/projects/OpenHaus/connector/node_modules/ws/lib/receiver.js:83:10)
    at writeOrBuffer (node:internal/streams/writable:391:12)
    at _write (node:internal/streams/writable:332:10)
[nodemon] app crashed - waiting for file changes before starting...

Accidental run npm run test in the backend folder while the connector was running.

Check for the interface array?
Even with the changes from OpenHausIO/backend#423 a empty interfaces array should exists so this error should never happens. (Perhaps because one interface was delete?)

@mStirner mStirner added the bug Something isn't working label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant