{"id":16347422,"url":"https://github.com/leebenson/hollaback","last_synced_at":"2025-04-12T09:32:57.850Z","repository":{"id":57264871,"uuid":"65576368","full_name":"leebenson/hollaback","owner":"leebenson","description":"Resolves a Promise when host(s)/port(s) are ready","archived":false,"fork":false,"pushed_at":"2018-08-21T06:35:19.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T04:51:09.420Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leebenson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-12T18:49:13.000Z","updated_at":"2019-01-11T06:49:21.000Z","dependencies_parsed_at":"2022-08-25T03:40:25.252Z","dependency_job_id":null,"html_url":"https://github.com/leebenson/hollaback","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leebenson%2Fhollaback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leebenson%2Fhollaback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leebenson%2Fhollaback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leebenson%2Fhollaback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leebenson","download_url":"https://codeload.github.com/leebenson/hollaback/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248546327,"owners_count":21122294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T00:42:19.360Z","updated_at":"2025-04-12T09:32:57.549Z","avatar_url":"https://github.com/leebenson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hollaback\n\n#### Resolves a Promise when host(s)/port(s) are ready\n\nIf your app needs to wait for database connections, microservices or other stuff being available first, holla' has your back.\n\nYou can use it like this (assuming async/await in Node.js):\n\n```js\n# ... inside an async function\nawait hollaback(\n  'web-host:80',\n  'arangodb-host:8529'\n);\n\n// Do other stuff after web and ArangoDB are ready\n```\n\nI wrote this because I use Docker Compose a lot.\n\nJust though Docker _thinks_ a service is ready, doesn't mean it is. That means dependencies can break.\n\nI wanted a simple way to await a promise before moving on.\n\nHollaback is it.\n\n## Usage\n\nES5/commonjs:\n\n```js\nconst hollaback = require('hollaback');\n\nhollaback('host1:port', 'host2:port').then(function () {\n  // Our host names are available\n});\n```\n\nES6/ES7/ESM\n\n```js\nimport hollaback from 'hollaback'\n\nconst hosts = [\n  'host1:port',\n  'host2:port'\n];\n\n(async function whenReady(){\n  await hollaback(...hosts);\n  // Our services are ready - go nuts...\n\n}());\n\n```\n\nPass either a list of `host:port` strings or an array of them, and hollaback will try all of them before resolving the promise.\n\n## Options\n\nUnder the hood, it uses [Socket](https://nodejs.org/api/net.html#net_class_net_socket) to probe a host/port.\n\nBy default, retries occur every *500ms* until the port is available, and hollaback rejects after *30 seconds*.\n\nYou can override the defaults by passing an options object as the last param:\n\n```js\nhollaback(hosts, {\n    retry: 500, // per connection retry (in ms)\n    timeout: 30 * 1000, // global timeout (rejects after this time, in ms)\n    socketTimeout: 1000, // per connection timeout (in ms)\n})\n```\n\n## Compatibility\n\nDesigned for Node 0.12.15 and above.\n\nIt won't work in a browser.\n\n## Testing\n\nRun `npm run test`\n\n## Fair warning\n\nChecking that a host/port accepts a connection isn't fool-proof.\n\nMaybe the port accepts connections, but hasn't finished instantiating. Connections != ready to rock.\n\nThis does nothing more than attempt the initial connection. It doesn't 'speak' any underlying protocol other than raw TCP/IP, so it won't be able to tell, say, whether you're able to invoke SQL against a database.\n\nWith that said, it should be good enough for 95% of scenarios where you just want to test if there's something listening on the other end.\n\nIt's especially useful for stack orchestration using tools like Docker Compose, where services need to start in order and usually report (prematurely) that they're ready for linked services to spawn.\n\n## License\n\n[MIT](https://github.com/leebenson/hollaback/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleebenson%2Fhollaback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleebenson%2Fhollaback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleebenson%2Fhollaback/lists"}