So I keep getting this 'unexpected token u in JSON at position 0' error. I'm currently make a request from the main initiator which is making a gRPC request to customers gRPC server.
When I don't containerize my files and manually npm install packages in each directory, it works smoothly. However, for some reason when I containerize my files, it has this issue.
Usually this issue occurs with asynchronous requests (gRPC is async so makes sense), and I think they're racing to completion, but don't ever get to do so. But the dockerFile is literally doing what I'm doing manually (which works...)
I'm just currently lost as to why this is the case.
Error
Error:
undefined:1
undefined
^
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at horus.grabTrace (/usr/src/app/horus/horus.js:52:23)
at ClientUnaryCall.<anonymous> (/usr/src/app/main.js:119:8)
at ClientUnaryCall.emit (events.js:210:5)
at Object.onReceiveMetadata (/usr/src/app/node_modules/grpc/src/client_interceptors.js:1202:15)
at InterceptingListener._callNext (/usr/src/app/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveMetadata (/usr/src/app/node_modules/grpc/src/client_interceptors.js:582:8)
at callback (/usr/src/app/node_modules/grpc/src/client_interceptors.js:845:24)
File Structure
**3 Different Services**
**Books**
-stubs
-booksStub
-BooksServer.js
**Customers**
-stubs (2 stubs for intraservice request)
-booksStub
-customersStub
-customersServer.js
-Dockerfile
**Main**
-Main Initiator
-Dockerfile
Docker Files (All)
**Dockerfile (Customers Service)**
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
RUN npm install
RUN npm install nodemon -g
EXPOSE 6000
CMD ["nodemon", "customersServer.js"]
**Dockerfile (Books Service)**
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
RUN npm install
RUN npm install nodemon -g
EXPOSE 30043
CMD ["nodemon", "booksServer.js"]
**Dockerfile (Main Service)**
FROM node:12.14.0
WORKDIR /usr/src/app
COPY package*.json ./
COPY . /usr/src/app
RUN npm install
EXPOSE 4555
CMD ["node", "main.js"]