Skip to content
This repository was archived by the owner on Jun 17, 2021. It is now read-only.

Commit 88b4e48

Browse files
committed
fix(agent-options): Fix occurs exception when the serviceName is empty
1 parent 1ee2a6b commit 88b4e48

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

modules/nodejs-agent/lib/config/index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ AgentConfig.prototype.instanceUUID = function() {
6464
};
6565

6666
AgentConfig.prototype.initConfig = function(agentOptions) {
67-
if (!agentOptions.hasOwnProperty("serviceName")) {
68-
throw new Error("service name cannot be empty");
69-
}
70-
this._serviceName = agentOptions.serviceName || process.env.SW_SERVICE_NAME || "You Application";
71-
this._directServices = agentOptions.directServers || process.env.SW_DIRECT_SERVERS || "localhost:11800";
67+
this._serviceName = process.env.SW_SERVICE_NAME || (agentOptions && agentOptions.serviceName) || "You Application";
68+
this._directServices = process.env.SW_DIRECT_SERVERS || (agentOptions && agentOptions.directServers) || "localhost:11800";
7269
this._instanceUUID = agentOptions.instanceUUID || uuid();
7370
};
7471

0 commit comments

Comments
 (0)