bidi2pdf 0.1.2 โ†’ 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbc473cb8b54517914bfa958b1925d97db54ab3e6ee640a28101b48346077192
4
- data.tar.gz: 76c2d11f399a33a932f66348cfc3aad9d0c80f1e15407566b10d16a646b17d1c
3
+ metadata.gz: 715f3587349e1680386f0c485f45b91a6096143c07cc8b531ca7e284a9516615
4
+ data.tar.gz: 8914fd60cdb04510070dee6b6d7134a94666584583681e26e830824bbf457059
5
5
  SHA512:
6
- metadata.gz: eb72b6bc4eeb2a65172c37138be3f2af5129a046a217acaf90236532c323547e0f1456f7743c509015808389da586b145cd069a26a85bbc35278c44cfea32249
7
- data.tar.gz: e3b6d68003a6419e86fa33a68b51c065d7d60f95cc7bf657b12cb13ed5bef085938599b5387aca641b1a699ec47fab6804e300892b962a842d06748b061a1e5d
6
+ metadata.gz: a8e17273531b0131ef9e8b5454154996dbd340d18cbf16a151478b91234e1e53005e0ffb057e16d540f6870b8915bafbdf03831afc2d9b4e9d861494ca13c38f
7
+ data.tar.gz: d0a4d3b193fc51b681a2e3b54da5cc7cccf05cf578b908144eb7ca5988327f0ee938b07dce88ca826d37889a469e3f32a7da61c68bbb05b5913731aeb0cc9e38
data/.rubocop.yml CHANGED
@@ -48,6 +48,16 @@ RSpec/InstanceVariable:
48
48
  RSpec/BeforeAfterAll:
49
49
  Enabled: false
50
50
 
51
+ RSpec/SpecFilePathFormat:
52
+ Enabled: true
53
+ Exclude:
54
+ - 'spec/acceptance/**/*_spec.rb'
55
+
56
+ RSpec/DescribeClass:
57
+ Enabled: true
58
+ Exclude:
59
+ - 'spec/acceptance/**/*_spec.rb'
60
+
51
61
  plugins:
52
62
  - rubocop-rake
53
63
  - rubocop-rspec
data/CHANGELOG.md CHANGED
@@ -6,8 +6,20 @@ All notable changes to this project will be documented in this file.
6
6
 
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
+
10
+ ## [Unreleased]
11
+
12
+ [unreleased]: https://github.com/dieter-medium/bidi2pdf/compare/v0.1.2..HEAD
13
+
9
14
  <!-- generated by git-cliff end -->
10
15
 
16
+ ## [0.1.3] - 2025-04-06
17
+
18
+ ### ๐Ÿ› Fixed
19
+
20
+ - Improve zombie process detection and termination logic in Chromedriver manager by @dieter-medium
21
+ - Add close method for WebSocket connection and update session close logic. Don't leak threads. by @dieter-medium
22
+
11
23
  ## [0.1.2] - 2025-04-05
12
24
 
13
25
  ### ๐Ÿ”„ Changed
data/cliff.toml CHANGED
@@ -79,33 +79,57 @@ commit_preprocessors = [
79
79
  ]
80
80
  # regex for parsing and grouping commits
81
81
  commit_parsers = [
82
- # โœ… Additions
83
- { message = "^[a|A]dd", group = "๐Ÿš€ Added" },
84
- { message = "^[s|S]upport", group = "๐Ÿš€ Added" },
85
- { message = "^.*: add", group = "๐Ÿš€ Added" },
86
- { message = "^.*: support", group = "๐Ÿš€ Added" },
87
-
88
- # โŒ Removals
89
- { message = "^[r|R]emove", group = "๐Ÿ—‘๏ธ Removed" },
90
- { message = "^.*: remove", group = "๐Ÿ—‘๏ธ Removed" },
91
- { message = "^.*: delete", group = "๐Ÿ—‘๏ธ Removed" },
92
-
93
- # ๐Ÿ› Fixes
94
- { message = "^test", group = "๐Ÿ› Fixed" },
95
- { message = "^fix", group = "๐Ÿ› Fixed" },
96
- { message = "^.*: fix", group = "๐Ÿ› Fixed" },
97
-
98
- # โ›”๏ธ Chore & CI commits to skip
99
- { message = "^chore\\(release\\): prepare for", skip = true },
100
- { message = "^chore\\(deps.*\\)", skip = true },
101
- { message = "^chore\\(pr\\)", skip = true },
102
- { message = "^chore\\(pull\\)", skip = true },
103
- { message = "^chore", skip = true },
104
- { message = "^ci", skip = true },
105
-
106
- # ๐ŸŒ€ Catch-All
107
- { message = "^.*", group = "๐Ÿ”„ Changed" }
82
+ # โœ… Features (additions)
83
+ { message = "^feat(?:\\([^)]+\\))?!?:", group = "๐Ÿš€ Added" },
84
+ { message = "^[aA]dd", group = "๐Ÿš€ Added" },
85
+ { message = "^[sS]upport", group = "๐Ÿš€ Added" },
86
+
87
+ # โŒ Removals
88
+ { message = "^[rR]emove", group = "๐Ÿ—‘๏ธ Removed" },
89
+ { message = "^[dD]elete", group = "๐Ÿ—‘๏ธ Removed" },
90
+
91
+ # ๐Ÿ› Fixes
92
+ { message = "^fix(?:\\([^)]+\\))?!?:", group = "๐Ÿ› Fixed" },
93
+ { message = "^[tT]est", group = "๐Ÿ› Fixed" },
94
+ { message = "^[fF]ix", group = "๐Ÿ› Fixed" },
95
+
96
+ # ๐ŸŽจ Refactors
97
+ { message = "^refactor(?:\\([^)]+\\))?!?:", group = "๐ŸŽจ Refactored" },
98
+
99
+ # โšก๏ธ Performance
100
+ { message = "^perf(?:\\([^)]+\\))?!?:", group = "โšก๏ธ Performance" },
101
+
102
+ # ๐Ÿ“ Docs
103
+ { message = "^docs(?:\\([^)]+\\))?!?:", group = "๐Ÿ“ Docs" },
104
+
105
+ # ๐Ÿ’„ Style (formatting, whitespace, etc.)
106
+ { message = "^style(?:\\([^)]+\\))?!?:", group = "๐Ÿ’„ Style" },
107
+
108
+ # ๐Ÿงช Tests
109
+ { message = "^test(?:\\([^)]+\\))?!?:", group = "๐Ÿงช Tests" },
110
+
111
+ # ๐Ÿ”ง Build
112
+ { message = "^build(?:\\([^)]+\\))?!?:", group = "๐Ÿ”ง Build" },
113
+
114
+ # ๐Ÿ› ๏ธ CI
115
+ { message = "^ci(?:\\([^)]+\\))?!?:", skip = true },
116
+
117
+ # ๐Ÿงน Chores (skip)
118
+ { message = "^chore\\(release\\): prepare for", skip = true },
119
+ { message = "^chore\\(deps.*\\)", skip = true },
120
+ { message = "^chore\\(pr\\)", skip = true },
121
+ { message = "^chore\\(pull\\)", skip = true },
122
+ { message = "^chore(?:\\([^)]+\\))?!?:", skip = true },
123
+ { message = "^\\s*chore", skip = true },
124
+
125
+ # โช Reverts
126
+ { message = "^revert(?:\\([^)]+\\))?!?:", group = "โช Reverted" },
127
+
128
+ # ๐ŸŒ€ Catch-all (only if nothing else matched)
129
+ { message = "^.*", group = "๐Ÿ”„ Changed" }
108
130
  ]
131
+
132
+
109
133
  # filter out the commits that are not matched by commit parsers
110
134
  filter_commits = false
111
135
  # sort the tags topologically
@@ -39,4 +39,10 @@ server {
39
39
  return 403;
40
40
  }
41
41
  }
42
+
43
+ location /nginx_status {
44
+ stub_status on;
45
+
46
+ access_log off;
47
+ }
42
48
  }
@@ -18,14 +18,6 @@ module Bidi2pdf
18
18
 
19
19
  def initialize(ws_url)
20
20
  @ws_url = ws_url
21
- @id = 0
22
- @pending_responses = {}
23
-
24
- @connected = false
25
- @connection_mutex = Mutex.new
26
- @next_id_mutex = Mutex.new
27
- @connection_cv = ConditionVariable.new
28
-
29
21
  @started = false
30
22
  end
31
23
 
@@ -103,6 +95,15 @@ module Bidi2pdf
103
95
  )
104
96
  end
105
97
 
98
+ def close
99
+ return unless @socket
100
+
101
+ Bidi2pdf.logger.debug "Closing WebSocket connection"
102
+ @socket&.close
103
+ @socket = nil
104
+ @started = false
105
+ end
106
+
106
107
  private
107
108
 
108
109
  def dispatcher
@@ -10,19 +10,9 @@ require_relative "user_context"
10
10
  module Bidi2pdf
11
11
  module Bidi
12
12
  class Session
13
- SUBSCRIBE_EVENTS = [
14
- "browsingContext",
15
- "network",
16
- "log",
17
- "script",
18
- "goog:cdp.Debugger.scriptParsed",
19
- "goog:cdp.CSS.styleSheetAdded",
20
- "goog:cdp.Runtime.executionContextsCleared",
21
- # Tracing
22
- "goog:cdp.Tracing.tracingComplete",
23
- "goog:cdp.Network.requestWillBeSent",
24
- "goog:cdp.Debugger.scriptParsed",
25
- "goog:cdp.Page.screencastFrame"
13
+ SUBSCRIBE_EVENTS = %w[
14
+ log
15
+ script
26
16
  ].freeze
27
17
 
28
18
  attr_reader :session_uri, :started
@@ -48,6 +38,7 @@ module Bidi2pdf
48
38
  def close
49
39
  client&.send_cmd_and_wait("session.end", {}) do |response|
50
40
  Bidi2pdf.logger.debug "Session ended: #{response}"
41
+ @client&.close
51
42
  @client = nil
52
43
  @websocket_url = nil
53
44
  @browser = nil
@@ -55,9 +55,11 @@ module Bidi2pdf
55
55
 
56
56
  close_session
57
57
 
58
- term_chromedriver
58
+ debug_show_all_children
59
+
60
+ old_childprocesses = term_chromedriver
59
61
 
60
- detect_zombie_processes
62
+ detect_zombie_processes old_childprocesses
61
63
 
62
64
  return unless process_alive?
63
65
 
@@ -68,14 +70,10 @@ module Bidi2pdf
68
70
 
69
71
  private
70
72
 
71
- # rubocop:disable Metrics/AbcSize
72
- def detect_zombie_processes
73
- debug_show_all_children
73
+ def detect_zombie_processes(old_childprocesses)
74
+ Bidi2pdf.logger.debug "Old child processes for #{@pid}: #{old_childprocesses.map(&:pid).join(", ")}"
74
75
 
75
- child_processes = Bidi2pdf::ProcessTree.new(@pid).children(@pid)
76
- Bidi2pdf.logger.debug "Found child processes: #{child_processes.map(&:pid).join(", ")}"
77
-
78
- zombie_processes = child_processes.select { |child| process_alive? child.pid }
76
+ zombie_processes = old_childprocesses.select { |child| process_alive? child.pid }
79
77
 
80
78
  return if zombie_processes.empty?
81
79
 
@@ -83,9 +81,18 @@ module Bidi2pdf
83
81
  printable_zombie_processes_str = printable_zombie_processes.join(", ")
84
82
 
85
83
  Bidi2pdf.logger.error "Zombie Processes detected #{printable_zombie_processes_str}"
84
+
85
+ term_zombie_processes zombie_processes
86
86
  end
87
87
 
88
- # rubocop:enable Metrics/AbcSize
88
+ def term_zombie_processes(zombie_processes)
89
+ Bidi2pdf.logger.info "Terminating zombie processes: #{zombie_processes.map(&:pid).join(", ")}"
90
+
91
+ zombie_processes.each do |child|
92
+ Bidi2pdf.logger.debug "Terminating PID #{child.pid} (#{child.name})"
93
+ Process.kill("TERM", child.pid)
94
+ end
95
+ end
89
96
 
90
97
  def debug_show_all_children
91
98
  Bidi2pdf::ProcessTree.new(@pid).traverse do |process, level|
@@ -103,9 +110,11 @@ module Bidi2pdf
103
110
  end
104
111
 
105
112
  def term_chromedriver
106
- Bidi2pdf.logger.info "Stopping Chromedriver (PID #{@pid})"
113
+ Bidi2pdf::ProcessTree.new(@pid).children(@pid).tap do |_child_processes|
114
+ Bidi2pdf.logger.info "Stopping Chromedriver (PID #{@pid})"
107
115
 
108
- Process.kill("TERM", @pid)
116
+ Process.kill("TERM", @pid)
117
+ end
109
118
  rescue Errno::ESRCH
110
119
  Bidi2pdf.logger.debug "Process already gone"
111
120
  @pid = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bidi2pdf
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bidi2pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dieter S.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-05 00:00:00.000000000 Z
11
+ date: 2025-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64